system.diagnostics.contracts.contract 存在于 v4.0 v3.5 中

发布于 2024-09-14 11:01:17 字数 147 浏览 9 评论 0原文

我刚刚升级到 Visual Studio 2010 并安装了代码合同 msi。当我尝试使用它时,出现编译器错误,指出 v3.5 和 v4 框架中都存在 system.diagnostics.contracts.contract dll。有人知道我应该做什么来解决这个问题吗?谢谢。

I just upgraded to visual studio 2010 and installed the code contracts msi. When I try to use it I get a compiler error that the system.diagnostics.contracts.contract dll exists in both the v3.5 and v4 framework. Anyone know what I should do to resolve this? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

污味仙女 2024-09-21 11:01:17

如果要将使用协定的 .NET 3.5 项目升级到 .NET 4.0,请确保删除对 Microsoft.Contracts 程序集的引用。

Microsoft.Contracts 程序集提供了在 .NET 2.0 或 3.5 项目中使用的代码契约,但默认情况下随 mscorlib 中的 .NET 4.0 一起提供,因此您不需要它。它们都共享 System.Diagnostics.Contracts 命名空间,因此通过同时引用两者,编译器无法确定您正在尝试使用哪一个。

If you're upgrading a .NET 3.5 project that uses contracts to .NET 4.0, make sure you remove your reference to the Microsoft.Contracts assembly.

The Microsoft.Contracts assembly provides code contracts for use in .NET 2.0 or 3.5 projects, but is provided by default with .NET 4.0 in mscorlib, so you don't need it. They both share the System.Diagnostics.Contracts namespace, so by having references to both at the same time, the compiler isn't able to figure out which one you're trying to use.

娇柔作态 2024-09-21 11:01:17

我通过首先安装它来解决它,但你实际上并没有解决它。
然后删除了引用,然后我将项目版本更改为 4.5,之后,它就起作用了。

I solved it by first installing it, thou that did not actually solve it.
Then removed the references and then I changed the project versions to 4.5 and after that, it worked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文