Including SendGrid breaks compile

北城余情 提交于 2019-12-10 15:36:12

问题


I've just downloaded SendGrid via Nuget and am trying to use it in one of my projects in a Solution.

I have the following references:

And referenced in my file:

And this code:

But I get the error "The type or namespace name 'SendGridMessage' could not be found (are you missing a using directive or assembly reference?)":

What's wrong with the above?


回答1:


SendGrid has now added a fork to nuget for .Net 4.0 support. If you want to keep using .Net 4.0 then you can install the SendGrid.Net40 package using the Visual Studio NuGet Console Manager with the following line:

Install-Package SendGrid.Net40

Here is the link to SendGrid that mentions that it has been forked: https://github.com/sendgrid/sendgrid-csharp/issues/112

and a link to the SendGrid.Net4.0 NuGet Gallery: https://www.nuget.org/packages/SendGrid.Net40/




回答2:


Turns out it needs .NET Framework 4.5, not 4.0 as the documentation says.

=========== EDIT: ===========

In response to @bwest's comment, here's what I tried:

Empty console app, .NET Framework V4:

Switch to .NET Framework v4.5:




回答3:


Following a tutorial on Microsoft, I run into this same problem. I googled around and foun the solution in this github forum

Basically its suggesting installing the correct SendGrid API version from NuGet. So in my case what finally resolved the issue is when I uninstalled the latest and installed V2 API (Install-Package Sendgrid -Version 6.3.4)



来源:https://stackoverflow.com/questions/24242059/including-sendgrid-breaks-compile

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!