带有 HttpClient 的 Service Fabric 服务抛出异常
Service Fabric Service with HttpClient throws exception
每当我调用创建新 HttpClient() 的方法时,我都会遇到异常。没有线索,因为 System.Net.Http 已被引用。
public async Task<Stuff> GetOrder(int id)
{
var t = new HttpClient();
}
"InnerException": {
"ClassName": "System.IO.FileNotFoundException",
"Message": "Could not load file or assembly 'System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.",
有什么想法吗?
问题是由以下原因引起的:
Microsoft.Extensions.Configuration.Abstractions
每当我引用这个程序集时,它就会抛出这个错误。我在使用 API 配置文件时需要这个。因此,解决方法是不让 Resharper 添加对 Http.Net 的引用,而是让 NuGet 引用 HttpClient。
<package id="System.Net.Http" version="4.3.3" targetFramework="net461" />
每当我调用创建新 HttpClient() 的方法时,我都会遇到异常。没有线索,因为 System.Net.Http 已被引用。
public async Task<Stuff> GetOrder(int id)
{
var t = new HttpClient();
}
"InnerException": { "ClassName": "System.IO.FileNotFoundException", "Message": "Could not load file or assembly 'System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.",
有什么想法吗?
问题是由以下原因引起的:
Microsoft.Extensions.Configuration.Abstractions
每当我引用这个程序集时,它就会抛出这个错误。我在使用 API 配置文件时需要这个。因此,解决方法是不让 Resharper 添加对 Http.Net 的引用,而是让 NuGet 引用 HttpClient。
<package id="System.Net.Http" version="4.3.3" targetFramework="net461" />