2016-08-16 73 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" />