2016-08-16 74 views
1

我有一个Web窗体应用程序,它具有与自己的项目单独的dll中的所有业务逻辑。该DLL需要有两个不同版本的Newtonsoft.json。我已经尝试在网站web.config和dll app.config文件中使用下面的代码,但我无法让应用程序从我指定的文件夹加载dll:s。我仍然收到以下消息:“无法加载文件或程序集”Newtonsoft.Json,Version = 4.5.0.0,Culture = neutral,PublicKeyToken = 30ad4fe6b2a6aeed“或它的某个依赖项。所在程序集的清单定义与程序集引用不匹配。 (从HRESULT异常:0x80131040)“有两个独立版本的DLL

任何想法,我可能做错了什么?

<runtime> 
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
    <dependentAssembly> 
    <!--<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> 
    <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />--> 

    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken ="30ad4fe6b2a6aeed" culture="neutral" /> 
    <bindingRedirect oldVersion="4.5.0.0" newVersion="5.0.1.0" /> 
    <bindingRedirect oldVersion="5.0.2.0-99.0.0.0" newVersion="7.0.1.0" /> 
    <codeBase version="4.5.0.0" href="Bin/Newtonsoft.Json/5.0.1.0/Newtonsoft.Json.dll" /> 
    <codeBase version="5.0.1.0" href="Bin/Newtonsoft.Json/5.0.1.0/Newtonsoft.Json.dll" /> 
    <codeBase version="7.0.1.0" href="Bin/Newtonsoft.Json/7.0.1.18622/Newtonsoft.Json.dll" /> 

    <!--<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> 
    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="7.0.1.0" />--> 

    </dependentAssembly> 
</assemblyBinding> 

解决:添加以下两个webconfig和AppConfig的<bindingRedirect oldVersion="0.0.0.0-99.0.0.0" newVersion="7.0.1.0" />

+1

我不知道为什么你需要做到这一点。 .. –

+0

我使用Dropbox.API和Hangfire,他们使用不同版本的Newtonsoft.Json – user1454695

+0

为什么你需要两个版本? – Brandon

回答

1

添加以下两个webconfig和AppConfig的<bindingRedirect oldVersion="0.0.0.0-99.0.0.0" newVersion="7.0.1.0" />