我有以下情况:
- A.dll 版本 1.0.0.1
B.dll 版本 1.0.0.1 依赖于 A.dll。使用 SpecificVersion = False 设置引用
<Reference Include="A"> <HintPath>A.dll</HintPath> <SpecificVersion>False</SpecificVersion> </Reference>
C.exe 使用
Assembly.LoadFrom("B.dll")
B.dll 加载
如果我将 A.dll 的版本更改为 1.0.0.2,我会在 Assembly.LoadFrom("B.dll")
上收到 FileNotFoundException,表示找不到 A.dll 1.0.0.1 (此时只有 A.dll 1.0.02 存在,但这并不重要,因为 SpecificVersion 为 false)
最佳答案
您可以按照 Hans 在评论中建议的那样使用程序集绑定(bind)重定向:
<dependentAssembly>
<assemblyIdentity name="someAssembly"
publicKeyToken="32ab4ba45e0a69a1"
culture="en-us" />
<bindingRedirect oldVersion="7.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
请参阅此链接了解更多信息 http://msdn.microsoft.com/en-us/library/7wd6ex19(v=vs.110).aspx
关于.net - C# 项目引用设置 SpecificVersion = False 似乎不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22403138/