C#项目引用设置SpecificVersion = False似乎不起作用

时间:2014-03-14 10:59:29

标签: .net dll reflection assemblyversions

我有以下情况:

  • 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是假的)

1 个答案:

答案 0 :(得分:2)

你可以像汉斯在评论中所建议的那样使用程序集绑定重定向:

<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