gpt4 book ai didi

带有 SendGrid 的 Azure Functions 无法在 Visual Studio 中编译

转载 作者:行者123 更新时间:2023-12-03 01:43:20 25 4
gpt4 key购买 nike

我正在尝试在 Visual Studio 中使用 SendGrid 来运行 Azure Functions 的简单示例:

[FunctionName("SendEmail")]
public static void SendEmail([HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] [SendGrid()] out Mail message)
{
message = new Mail
{
Subject = "From VS"
};

var personalization = new Personalization();
// change to email of recipient
personalization.AddTo(new Email("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7f15101a3f191010511c1012" rel="noreferrer noopener nofollow">[email protected]</a>"));

Content content = new Content
{
Type = "text/plain",
Value = "testing from VS."
};

message.AddContent(content);
message.AddPersonalization(personalization);
}

但是我收到以下编译错误:

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Azure.WebJobs, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

除了这些警告之外: enter image description here

我安装了 Visual Studio 2017 15.7.1。该项目面向 .NET Standard 2.0,我的项目安装了以下 NuGet 包:

enter image description here

我需要安装或删除什么才能进行编译?

最佳答案

在引用 Microsoft.Azure.WebJobs.Extensions.SendGrid 版本 2.2.0 包时,我进一步观察到了生成警告,因为它与 .NET Standard 不兼容。将软件包升级到版本 3.0.0-beta5 后,警告消失了。此外,请注意,这意味着使用测试版产品,在发布任何生产代码之前对其进行彻底测试。

 1. 'Microsoft.Azure.WebJobs.Extensions.SendGrid 2.2.0' was restored   
using '.NETFramework,Version=v4.6.1' instead of the project target
framework '.NETStandard,Version=v2.0'. This package may not be fully
compatible with your project.
2. 'Sendgrid 8.0.5' was restored using '.NETFramework,Version=v4.6.1'
instead of the project target framework '.NETStandard,Version=v2.0'.
This package may not be fully compatible with your project.
3. 'SendGrid.CSharp.HTTP.Client 3.0.0' was restored using
'.NETFramework,Version=v4.6.1' instead of the project target
framework '.NETStandard,Version=v2.0'. This package may not be fully
compatible with your project.

关于带有 SendGrid 的 Azure Functions 无法在 Visual Studio 中编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50440025/

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