运行 Asp.Net 中并行的相同 Dll 的两个版本

Running two versions of same Dll parallel in Asp.Net

我需要 运行 同一 Dll 的两个版本同时 运行 在我的网站上。所以我在 Bin 中创建了一个文件夹,并像这样显示了第二个 Dll 路径

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
     <dependentAssembly>
        <assemblyIdentity name="AWSSDK"  culture="neutral" publicKeyToken="9f476d3089b52be3"/>
        <codeBase version="2.3.40.0" href="FILE://E://Live /bin/V-2/AWSSDK.dll"/>
     </dependentAssembly>
  </assemblyBinding>

并在 bin 文件夹中添加了我的第一个普通 dll。但是当我尝试访问我的 AWSSDK 2.3 Dll 中的任何函数时,它会抛出这样的错误

"Could not load file or assembly 'AWSSDK, Version=2.3.41.0, Culture=neutral, PublicKeyToken=9f476d3089b52be3' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"AWSSDK, Version=2.3.41.0, Culture=neutral, PublicKeyToken=9f476d3089b52be3"

任何人都可以指出我在这里做错了什么吗?

此错误是因为您可能拥有不同版本的 ddl,但命名空间将相同,并且您只能在项目中引用不同的命名空间。

为了克服这个问题, 为两个版本创建不同的名称空间或 使用 strong names for assemblies.