Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while installing package in ASP.NET core app

I am using VS 2017 to create ASP.NET Core Web app. While installing Sendgrid package, I am getting following error.

Package Sendgrid 8.0.5 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Sendgrid 8.0.5 supports: net (.NETFramework,Version=v0.0) Package Microsoft.AspNet.WebApi.Client 5.2.3 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Microsoft.AspNet.WebApi.Client 5.2.3 supports: net45 (.NETFramework,Version=v4.5) portable-net45+netcore45+wp8+wp81+wpa81 (.NETPortable,Version=v0.0,Profile=wp8+netcore45+net45+wp81+wpa81) Package SendGrid.CSharp.HTTP.Client 3.0.0 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package SendGrid.CSharp.HTTP.Client 3.0.0 supports: net (.NETFramework,Version=v0.0) One or more packages are incompatible with .NETCoreApp,Version=v1.0.`

Any solution for this error?

like image 477
Ajay Kumar Avatar asked Mar 21 '26 03:03

Ajay Kumar


2 Answers

You might need to use the pre-release version.

https://www.nuget.org/packages/SendGrid.NetCore/

like image 127
ChaiNavawongse Avatar answered Mar 23 '26 19:03

ChaiNavawongse


The error gives you this support matrix for SendGrid 8.0.5 and its dependencies.

                                net     net45   portable-net45+netcore45+wp8+wp81+wpa81
SendGrid                         1
Microsoft.AspNet.WebApi.Client            1             1
SendGrid.CSharp.HTTP.Client      1

You can see that none of them support the Core Framework (netcoreapp) and instead require the Full Framework (net).

If you require your app to run on the Core Framework, you cannot use SendGrid 8.0.5. Your options include (but are not limited to) using SendGrid.NetCore or using MailKit.

If you do not require your app to run on the Core Framework and are okay supporting only the Full Framework (net), then you can use SendGrid 8.0.5.

For our own apps, we've elected to use MailKit version 1.10.0, because it is more mature than SendGrid.NetCore is and it supports the Core Framework. We use it as follows:

project.json

"dependencies": {                                                        
    "MailKit": "1.10.0"                                                  
},                                                                       
"frameworks": {                                                          
    "netcoreapp1.1": {}                                                  
}

Send an email using SendGrid with MailKit.

var mimeMessage = new MimeMessage();
mimeMessage.From.Add(new MailboxAddress("Admin", "[email protected]"));
mimeMessage.To.Add(new MailboxAddress("Jon Doe", "[email protected]"));
mimeMessage.Subject = "An Email for You!";
mimeMessage.Body = new TextPart("html")
{
    Text = "This is the message.";
};

using (var client = new SmtpClient())
{
    client.ServerCertificateValidationCallback = (s, c, h, e) => true;
    client.Connect("smtp.sendgrid.net", 587);
    await client.AuthenticateAsync("[email protected]", "ASD43234GDX");    
    await client.SendAsync(mimeMessage);
    client.Disconnect(true);  
}
like image 28
Shaun Luttin Avatar answered Mar 23 '26 19:03

Shaun Luttin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!