我有一个 C# 类库MyLibrary,我在其中引用了sample.dll 版本 2.7.0。这个 MyLibrary 在 WCF 项目中被引用。哪个部署在服务器上。
现在在服务器上,我有版本 3.0.0的 sample.dll,因为我得到了以下引用的 dll not found 错误。
无法加载文件或程序集 'sample, Version=2.7.0.0, Culture=neutral, PublicKeyToken=185805eaf7302b6c' 或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。(来自 HRESULT 的异常:0x80131040)
我发现很少有使其版本独立的解决方案,例如添加“BindingRedirect”,因为它是一个类库,我没有可以配置“BindingRedirect”的 web.config 或 app.config。我也尝试将“特定版本”设置为 false,但仍然出现相同的错误。
我想让我的类库可以与任何版本的 Sample dll 一起使用
我尝试在我的 WCF 项目的 web.config 中添加以下内容
<dependentAssembly>
<assemblyIdentity name="sample" publicKeyToken="185805eaf7302b6c" culture="neutral"/>
<bindingRedirect oldVersion="2.7.0.0" newVersion="3.0.0.3"/>
</dependentAssembly>
但仍然得到同样的错误。