[英]Linking to a .Net v2.0 assembly from a .Net v4.0 assembly also appears to link (and alias) mscorlib v2.0. Why?
I have a .Net assembly which imports an assembly linked against the v2.0 runtime. 我有一个.Net程序集,它导入了与v2.0运行时链接的程序集。 The problem I'm having is that when I try to run some tests on my assembly, Fusion trys to load the wrong version of a dependent assembly.
我遇到的问题是,当我尝试在程序集上运行一些测试时,Fusion尝试加载错误版本的从属程序集。
After looking at the assembly manifest, I can see why: the wrong version of FSharp.Core
is linked. 查看程序集清单后,我可以看到原因:链接了错误版本的
FSharp.Core
。 In my build file, I make FSharp.Core, Version=4.0.0.0
explicit, but FSharpPowerPack
appears to link to v2.0.0.0, and some how seems to "win" this linking battle. 在我的构建文件中,我明确显示了
FSharp.Core, Version=4.0.0.0
,但FSharpPowerPack
似乎链接到v2.0.0.0,并且有些人似乎“赢得”了这场链接之战。
Here's the manifest: 这是清单:
// Metadata version: v4.0.30319
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly extern System.Core
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly extern System
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly extern FSharp.PowerPack
{
.publickeytoken = (A1 90 89 B1 C7 4D 08 09 ) // .....M..
.ver 2:0:0:0
}
.assembly extern mscorlib as mscorlib_8
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 2:0:0:0
}
.assembly extern System.Core as System.Core_9
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 3:5:0:0
}
.assembly extern FSharp.Core
{
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....:
.ver 2:0:0:0
}
Note that it seems that by including FSharpPowerPack
the v2.0 and v3.5 of other .Net assemblies (mscorlib, System, System.Core) are included and aliased. 请注意,似乎通过包含
FSharpPowerPack
,其他.Net程序集(mscorlib,System,System.Core)的v2.0和v3.5也包括在内并具有别名。 Why does this happen? 为什么会这样? Is this related to the issue of loading the wrong version of
FSharp.Core
? 这是否与加载错误版本的
FSharp.Core
?
Edit: To clarify, my assembly is being generated by the C# v4.0 compiler. 编辑:澄清一下,我的程序集是由C#v4.0编译器生成的。
Are you in control of the application which will load the compiled assembly? 您是否在控制将加载已编译程序集的应用程序? If so, you could use a binding redirect in your app.config file to force all FSharp.Core references to use version 4.0:
如果是这样,则可以在app.config文件中使用绑定重定向来强制所有FSharp.Core引用使用版本4.0:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="4.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
If you are having the problem with an automated test application, you might be able to edit its config file in a similar way, assuming it doesn't affect its operation. 如果您在自动化测试应用程序方面遇到问题,则可以假定它不影响其操作,并且可以通过类似的方式编辑其配置文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.