无法加载文件或程序集'SendGrid,版本= 9.10.0.0

时间:2019-01-09 12:34:34

标签: asp.net authentication passwords sendgrid

我正在尝试连接SendGrid以进行自动帐户确认和密码恢复。我正在使用ASP.net Webform应用程序和c#。我已经安装了NuGet SendGrid软件包。我正在尝试修改IdentityConfig.cs文件。

该软件包可以正常运行。当我注册一个新用户时,出现以下错误: 无法加载文件或程序集'SendGrid,版本= 9.10.0.0,区域性=中性,PublicKeyToken = 4f047e93159395ca'或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。 (来自HRESULT的异常:0x80131040)

但是,用户确实被添加到ASPNetUsers数据库表中。

一如既往,我非常感谢您的帮助。 我的代码是:

using System;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin;
using Microsoft.Owin.Security;
using SendGrid.Models;
using SendGrid.Helpers.Mail;
using System.Collections.Generic;

namespace SendGrid
{
public class EmailService : IIdentityMessageService
{
    public async Task SendAsync(IdentityMessage message)
    {
        await configSendGridasync(message);
    }

    // Use NuGet to install SendGrid (Basic C# client lib) 
    private async Task configSendGridasync(IdentityMessage message)
    {
        var apiKey = System.Web.Configuration.WebConfigurationManager.AppSettings["SendGrid_API_Key"];
        var client = new SendGridClient(apiKey);
        var msg = new SendGridMessage();

        msg.SetFrom(new EmailAddress("azure_test@azure.com", "Me"));

        msg.AddTo(message.Destination);

        msg.SetSubject("Testing the SendGrid C# Library");

        msg.AddContent(MimeType.Text, "Hello World plain text!");
        msg.AddContent(MimeType.Html, "<p>Hello World!</p>");

        var response = await client.SendEmailAsync(msg);

        // Create a Web transport for sending email.
        //var transportWeb = new Web(credentials);

        //// Send the email.
        //if (transportWeb != null)
        //{
        //    await transportWeb.DeliverAsync(msg);
        //}
        //else
        //{
        //    Trace.TraceError("Failed to create Web transport.");
        //    await Task.FromResult(0);
        //}
    }
}

0 个答案:

没有答案