【发布时间】:2017-02-24 20:50:08
【问题描述】:
我有一个 .NET 核心类库,它为 netstandard1.6 构建了一个 nuget 包。我想在 Azure 函数中使用这个库。但是当我尝试使用
调用类库中的方法时出现此错误using System.Net.Http;
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
return MyClassLib.Methode(req);
}
error CS1503: Argument 1: cannot convert from 'System.Net.Http.HttpRequestMessage [D:\home\data\Functions\packages\nuget\System.Net.Http\4.1.0\ref\net46\System.Net.Http.dll]' to 'System.Net.Http.HttpRequestMessage [D:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Net.Http.dll]'
我猜 D:\home\data\Functions\packages\nuget\System.Net.Http\4.1.0\ref\net46\System.Net.Http.dll 是来自“依赖项”的 dll: { “NETStandard.Library”:“1.6.0” },
我在 System.Net.Http 中发现了类似的问题:https://github.com/dotnet/corefx/issues/9846 我读到了一些关于:
未固定为 1.0 的软件包示例 "System.Net.Http":"4.1.0-*" https://docs.microsoft.com/en-us/dotnet/articles/core/tutorials/managing-package-dependency-versions
我应该因为 System.Net.Http 版本而降级到 netstandard 1.2 吗?但是我不能再支持net46了:https://github.com/dotnet/corefx/blob/master/Documentation/architecture/net-platform-standard.md
netstandard 和 net46 是否不匹配?
【问题讨论】:
标签: c# azure-functions dotnet-httpclient .net-standard