开发者

Referenced Assembly won't load

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开发者_如何学C 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?


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


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:

warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible

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.


I happens if the publish nuget package has wrong runtime/architecture or it is not .dotnet dll at all.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜