gpt4 book ai didi

c# - 无法加载文件或程序集 System.Net.Http 版本 4.1.1.0

转载 作者:IT王子 更新时间:2023-10-29 04:06:01 27 4
gpt4 key购买 nike

我正在将 Net Framework 4 dll 移植到 Net Core。移植我的单元测试项目时,我在运行某些特定测试(不是全部)时遇到异常。

System.IO.FileLoadException: Could not load file or assembly 'System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

这是我的 dll 的 project.json

 {
"version": "1.0.0-*",

"dependencies": {
"log4net": "2.0.7",
"NETStandard.Library": "1.6.1",
"Newtonsoft.Json": "9.0.1",
"StackExchange.Redis": "1.2.1"
},

"frameworks": {
"netstandard1.6": {
"imports": "dnxcore50"
}
}
}

这是单元测试项目的 Packages.config

<packages>
<package id="Castle.Core" version="4.0.0" targetFramework="net462" />
<package id="log4net" version="2.0.7" targetFramework="net462" />
<package id="Microsoft.Win32.Primitives" version="4.0.1" targetFramework="net462" />
<package id="Moq" version="4.7.1" targetFramework="net462" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net462" />
<package id="StackExchange.Redis" version="1.2.1" targetFramework="net462" />
<package id="System.Diagnostics.DiagnosticSource" version="4.0.0" targetFramework="net462" />
<package id="System.IO" version="4.1.0" targetFramework="net462" />
<package id="System.IO.FileSystem" version="4.0.1" targetFramework="net462" />
<package id="System.IO.FileSystem.Primitives" version="4.0.1" targetFramework="net462" />
<package id="System.IO.FileSystem.Watcher" version="4.0.0" targetFramework="net462" />
<package id="System.Linq" version="4.1.0" targetFramework="net462" />
<package id="System.Net.Http" version="4.1.1" targetFramework="net462" />
<package id="System.Net.NameResolution" version="4.0.0" targetFramework="net462" />
<package id="System.Runtime" version="4.1.0" targetFramework="net462" />
<package id="System.Runtime.Extensions" version="4.1.0" targetFramework="net462" />
<package id="System.Security.Cryptography.Algorithms" version="4.2.0" targetFramework="net462" />
<package id="System.Security.Cryptography.Encoding" version="4.0.0" targetFramework="net462" />
<package id="System.Security.Cryptography.Primitives" version="4.0.0" targetFramework="net462" />
<package id="System.Security.Cryptography.X509Certificates" version="4.1.0" targetFramework="net462" />
<package id="System.Text.RegularExpressions" version="4.1.0" targetFramework="net462" />
<package id="System.Threading.Thread" version="4.0.0" targetFramework="net462" />
</packages>

最佳答案

通过将 System.Net.Http 更新到 4.3.1 修复了它

关于c# - 无法加载文件或程序集 System.Net.Http 版本 4.1.1.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42720421/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com