问题描述
我有一个像这样开始的简单函数:
I have a simple function that start like this:
log.LogInformation($"Function started at: {DateTime.Now}");
try
{
string sourceStorageConnectionStringKvStorage = "https://mghfkeys.vault.azure.net/secrets/MGHBlackBaudStorageSecret/2e7a816d7b0840c0af2d0a428e0697ab";
AzureServiceTokenProvider azureServiceTokenProviderStorage = new AzureServiceTokenProvider();
var keyVaultClientStorage = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(azureServiceTokenProviderStorage.KeyVaultTokenCallback));
} catch (Exception ex)
{
log.LogInformation($"Function exception at: {ex.Message}");
}
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
在日志中,我有此变暖
run.csx(30,41):警告CS1701:假定程序集引用为'System.Net.Http,Version = 4.0.0.0, 由Microsoft.Azure.KeyVault使用的Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a匹配身份System.Net.Http,Version = 4.2.1.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a与System.Net.Http'的身份,您可能需要提供运行时策略
run.csx(30,41): warning CS1701: Assuming assembly reference 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' used by 'Microsoft.Azure.KeyVault' matches identity 'System.Net.Http, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' of 'System.Net.Http', you may need to supply runtime policy
导致这种异常的情况
函数异常位于:无法加载文件或程序集'System.Net.Http.WebRequest,版本= 4.0.0.0,区域性=中性, PublicKeyToken = b03f5f7f11d50a3a'.该系统找不到指定的文件.
Function exception at: Could not load file or assembly 'System.Net.Http.WebRequest, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
有什么办法解决这个问题吗?
Any idea how to fix this ?
谢谢
推荐答案
根据以下nuget页面,System.Net.Http包不包含WebRequest类型,该类型可能解释了您得到的错误:https://www.nuget.org/packages/System.Net.Http/
According to the following nuget page, the System.Net.Http package does not include the WebRequest type which likely explains the error you are getting: https://www.nuget.org/packages/System.Net.Http/
有一个名为System.Net.Requests的程序包,其中包含类型System.Net.HttpWebRequest.可以从以下nuget页面安装此软件包: https://www.nuget.org/packages/System.Net.Requests/
There is a package called System.Net.Requests that contains the type System.Net.HttpWebRequest. This package can be installed from the following nuget page: https://www.nuget.org/packages/System.Net.Requests/
我建议安装System.Net.Requests程序包,以查看是否出现相同的错误.
I would recommend installing the System.Net.Requests package to see if you get the same error.
如果此答案有帮助,请单击标记为答案"或向上投票.要提供有关您的论坛体验的其他反馈,请单击此处
If this answer was helpful, click "Mark as Answer" or Up-Vote. To provide additional feedback on your forum experience, clickHere
这篇关于System.Net.Http问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!