标签:
?
已经添加了nuget Microsoft.AspNet.WebApi.Client
调用System.Net.Http.HttpClient.PostAsJsonAsync的时候报如下的错误:
Could not load file or assembly ‘System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35‘ or one of its dependencies. The located assembly‘s manifest definition does not match the assembly reference. |
?
怎么回事那?
【分析】
查看了主网站的项目文件(.csproj)和DLL的项目文件(.csproj),发现两个项目中引用的.cspro版本不一致。
DLL的项目的引用如下:
<Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath> </Reference> |
?
主项目中的引用如下:
<Reference Include="System.Net.Http.Formatting, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll</HintPath> </Reference> |
?
这样就导致实际放到bin目录下的是5.2.2版本,这样DLL 项目就找不到5.2.3版本了。
?
【解决方法】
这几个地方5.2.2版本都要改成5.2.3.
<Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll</HintPath> </Reference> |
<dependentAssembly> <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.3.0" /> </dependentAssembly> |
?
System.Net.Http.Formatting的nuget版本冲突问题
标签:
原文地址:http://www.cnblogs.com/time-is-life/p/5594737.html