引用的程序集无法加载
我有一个 Visual Studio 2010 项目,它发布了一个名为 myAssembly.ddl
的程序集。 然后我想从现有的 vs 2008 项目中引用 myAssembly.dll
。如果我尝试加载引用,它旁边会出现一个黄色感叹号,表明该程序集未加载。但是,在此过程中我没有收到任何错误消息。显然,如果我尝试在代码中导入名称空间,它不会编译。
将 myAssembly.dll
转换为 .net 版本 3.5 没有帮助。 将程序集复制到不同的目录并从那里引用它也不起作用。
有什么想法吗?
I've got a visual studio 2010 project which publishes an assembly called myAssembly.ddl
.
I then want to reference myAssembly.dll
from an existing vs 2008 project. If I try to load the reference it comes up with an yellow exclamation mark next to it, suggesting that the assembly wasn't loaded. However, I'm not getting any error messages during that process. Obviously, if i try to import the namespace in my code it doesn't compile.
Converting myAssembly.dll
to a .net version 3.5 doesn help.
Nor does copying the assembly to a different directory and referencing it from there.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您使用哪个 .NET Framework 在 Visual Studio 2008 中构建解决方案?
它需要是 3.5 版本才能允许您使用使用 3.5 框架编译的 myAssembly.dll。 Visual Studio 2008 将允许您以 2.0 框架甚至 3.0 框架为目标。
Visual Studio 2008
项目>属性>应用选项卡
寻找目标框架
Which .NET Framework are you using to build the solution in Visual Studio 2008?
It needs to be version 3.5 in order to allow you to utilize the myAssembly.dll that you compiled with the 3.5 framework. Visual Studio 2008 will allow you to target the 2.0 Framework or even the 3.0 Framework.
Visual Studio 2008
Project > Properties > Application tab
Look for Target Framework
我得到了这个的复制品。在 Ildasm.exe 中可见,2010 编译器将元数据标记为 v4.0.30319。您还可以使用 Corflags.exe 来查看它。 2008 构建系统会为此生成警告,您可以在“输出”窗口中看到它:
将目标框架更改为 3.5 可以解决该问题,程序集现在将被标记为 v2.0.50727,这是 2005 年和 2008 年使用的 CLR 版本。但是 IDE 不够智能,无法检测到此更改。您必须删除程序集引用,然后将其放回去。黄色感叹号不再存在。
I get a repro for this. It is visible in Ildasm.exe, the 2010 compiler marks the metadata as v4.0.30319. You can also see it with Corflags.exe. The 2008 build system generates a warning for this, you can see it in the Output window:
Changing the Target Framework to 3.5 fixes the problem, the assembly will now be marked as v2.0.50727, the CLR version used in 2005 and 2008. The IDE is however not smart enough to detect this change. You'll have to remove the assembly reference, then put it back in. And the yellow exclamation mark is no longer there.
如果发布的 nuget 包有错误的运行时/架构或者它根本不是 .dotnet dll,我就会发生这种情况。
I happens if the publish nuget package has wrong runtime/architecture or it is not .dotnet dll at all.