VS 2010 .NET Framework 问题(针对 3.5 的程序集)抱怨它需要更高版本的 .NET Framework
我遇到了一个针对 .NET 3.5 的程序集的奇怪问题。当通过“添加引用/浏览到 DLL”包含此程序集时,它会抱怨:
“MyAssembly.dll”或其依赖项之一需要比项目中指定的版本更高的 .NET Framework 版本。您可以通过单击“项目”菜单上的“属性”,然后在“.NET Framework”下拉框中选择一个新目标来更改 .NET Framework 目标。 (在 Visual BVasic 中,通过单击“高级编译器选项...”按钮可以在“编译”选项卡上找到该选项。)是否仍要在项目中添加对“MyAssembly.dll”的引用?
这个错误似乎没有任何规律或原因 - 我们已经尝试了“明显”的事情。
使用 DLL 的程序集是 .NET 3.5。 该DLL是.NET 3.5。 每个使用的所有程序集都是 .NET 3.5。没有使用 .NET 4.0 [AFAIK]
我可以检查/执行哪些操作? DLL 中有一些 COM Interop - 是这样吗? 该项目已从 VS 08 移至 VS 10 - 但同样,目标仍然是 .NET 3.5。 我验证了参考下列出的所有程序集都以正确的 CLR 版本为目标 [2]。
将目标项目升级到 .NET 4 确实可以解决该问题 - 但这不是我们目前能够做的事情。
- 我还应该注意到,通过引用/项目 [相同的解决方案] 包含它似乎确实有效 - 将 DLL 降级到 .NET 3.0 时。 [这可能不完全准确 - 正在测试很多东西]
此时我已经没有想法了。
I'm having an odd issue with an assembly that is targeting .NET 3.5. When including this assembly via Add References/Browse to DLL - it complains:
"MyAssembly.dll", or one of its dependencies, requires a later version of the .NET Framework than the one specified in the project. You can change the .NET Framework target by clicking Properties on the Project menu and then selecting a new target in the '.NET Framework' dropdown box. (In Visual BVasic, this is located on the Compile tab by clicking the "Advanced Compiler Options..." button.) Do you still want to add a reference to 'MyAssembly.dll' in the project ?
There doesn't seem to be any rhyme or reason to this error - we've tried the "obvious' things.
The Assembly that is consuming the DLL is .NET 3.5.
The DLL is .NET 3.5.
All of the assemblies that each are using - are .NET 3.5. Nothing is using .NET 4.0 [AFAIK]
What things can I check/do ? There is some COM Interop in the DLL - could that be it ?
This project was moved from VS 08 to VS 10 - but again, still targets .NET 3.5.
I verified that all of the assemblies listed under Reference target the right CLR version [2].
Upgrading the target project to .NET 4 does remove the issue - but this isn't something we're able to do at this time.
- I should also note that including it via References/Project [same solution] does seem to work - when downgrading the DLL to .NET 3.0. [this may not be entirely accurate - was testing quite a few things]
I'm out of ideas at this point.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实证明,问题是.. 奇怪的是.. Janus Controls .NET 3.5 组件.. 与其他组件似乎不能很好地配合。
截至今天,Janus 控件 [GridEX] 无法与 VS 10 和 VS 10 一起使用。 .NET 3.5,...仅适用于 .NET 4 项目,即使解决方案是在 .NET 3.5 和 VS 2008 中构建的。
It turns out that the issue is.. oddly enough.. with Janus Controls .NET 3.5 components.. do not play well with others it seems.
As of today, the Janus Controls [GridEX] do not work with VS 10 & .NET 3.5, ... only with .NET 4 projects, even if the solution was built in .NET 3.5 and VS 2008.
我假设您已经使用 Reflector 或 ILDASM 来检查导致问题的程序集的清单。
您可以选择的一种选择是忽略该消息并添加引用。然后尝试在程序集中使用任何类型。您应该会收到更完整的错误消息。
例如,当我尝试引用面向更高框架的类库时,这是我在计算机中遇到的错误:
无法解析主要引用“ClassLibrary2”,因为它间接依赖于 .NET Framework 程序集” mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”,其版本“4.0.0.0”比当前目标框架中的版本“2.0.0.0”更高。 ConsoleApplication1
希望有助于查明问题。
I'm assuming that you already used Reflector or ILDASM to check the Manifest of the assemblies that are causing the problem.
One option you have is to ignore the message and add the reference anyway. Then try to use any type in the assembly. You should get a more complete error message.
For example, this is the error I get in my computer when I try to reference a class library that is targeting a higher framework:
The primary reference "ClassLibrary2" could not be resolved because it has an indirect dependency on the .NET Framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework. ConsoleApplication1
Hope that helps pinpoint the problem.