2017-06-18 52 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