2017-06-18 50 views
0

使用VS 2017. VB.Net應用程序。構建VB.Net應用程序和程序集警告

如果我做一個完整的編譯,我得到的警告如下:

1> Consider app.config remapping of assembly "System.Net.Http, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "4.0.0.0" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.Net.Http.dll] to Version "4.1.1.1" [D:\My Programs\2017\MeetSchedAssist\packages\System.Net.Http.4.3.2\lib\net46\System.Net.Http.dll] to solve conflict and get rid of warning. 
1> Consider app.config remapping of assembly "Newtonsoft.Json, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" from Version "9.0.0.0" [] to Version "10.0.0.0" [D:\My Programs\2017\MeetSchedAssist\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll] to solve conflict and get rid of warning. 


1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3276: Found conflicts between different versions of the same dependent assembly. Please set the "AutoGenerateBindingRedirects" property to true in the project file. For more information, see http://go.microsoft.com/fwlink/?LinkId=294190. 
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2042,5): warning MSB3836: The explicit binding redirect on "Newtonsoft.Json, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" conflicts with an autogenerated binding redirect. Consider removing it from the application configuration file or disabling autogenerated binding redirects. The build will replace it with: "<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" xmlns="urn:schemas-microsoft-com:asm.v1" />". 
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2042,5): warning MSB3836: The explicit binding redirect on "System.Net.Http, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" conflicts with an autogenerated binding redirect. Consider removing it from the application configuration file or disabling autogenerated binding redirects. The build will replace it with: "<bindingRedirect oldVersion="0.0.0.0-4.1.1.1" newVersion="4.1.1.1" xmlns="urn:schemas-microsoft-com:asm.v1" />". 

什麼是解決這些問題的正確方法是什麼?非常感謝你。

更新

根據所提供的答案,這裏是我的app.config文件。我已刪除簡稱爲清楚起見,所有其他組件:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <startup> 
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" /> 
    </startup> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 
</configuration> 

所以建議Ø從文件中刪除這兩個<dependentAssembly>完全?

回答

1

最有可能您所引用的System.Net.HttpNewtonsoft.Json正在使用與您的應用所依賴的.NET版本不匹配。嘗試從app.config文件中刪除綁定重定向。這可能會在下次構建時解決問題。

更新

根據您的錯誤消息的建議,你可以這樣做:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <startup> 
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" /> 
    </startup> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="10.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.1.1.1" /> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 
</configuration> 

分別改變兩個組件的版本10.0.0.0和4.1.1.1。我最初提議的是完全刪除<bindingRedirect oldVersion...元素,以便它不依賴於特定的版本,並且可以根據您的應用程序正在使用哪個版本的.NET來解決這些庫。

+0

感謝您的意見。請參閱我更新的問題,因爲我想確保我理解您的提案。或者,也許你可以用解決問題所需的方法充實你的答案?提前致謝。 –

+1

我查看了您的意見,並相應地編輯了我的答案。希望有所幫助。 – Fabulous