Hi,
I'm reasonably new to C# and Visual Studio. I'm stumped on a problem and hoping someone else can point me in the right direction.
I have a console application that I wrote to retrieve data from a vendor system via a primitive Web API (IBM's flavor of XML) and write it to my system's database (via SQL calls). The app works well and does what it should. It's a bit slow, but it works, updating 16,000 products in about 3 hours. Each product can be in multiple websites and there is some business logic being applied to maintain the data in my system.
I've recently upgraded to a new computer and had to reinstall Visual Studio. I'm running 2017 Community edition. I'm an Army of One, need to be thrifty as I'm a startup and Community does everything I need it to. I don't think this is the issue, but I'm including it here just in case.
I'm trying to add some code to my console application that will send me a status email via SendGrid's API. I'm following their example here: https://sendgrid.com/docs/Integrate/Code_Examples/v2_Mail/csharp.html
I've installed the package via NuGet.
The problem is that Visual Studio is ignoring my using statements. They remain dimmed out and when I try to build it complains that I don't have the SendGrid namespace defined. When I comment out the using statements and the sendgrid code it works fine. Before I give up and send via SMTP I'd like to see if I can solve the problem and learn something.
The Sendgrid helpers using is staying active, but the others are indicating that the namespace isn't being used.
For a variety of reasons I'm not including all of my code. Here is the pertinent parts that should execute Sendgrid and send me a status email:
I'm also getting a compile error "SendGridMessage .Subject cannot be used like a method. Along with a bunch of similar failures and a prompt about if I am missing a directive.
This is really frustrating as it's a pretty simple example and I've copied it exactly. What am I missing?
I'm reasonably new to C# and Visual Studio. I'm stumped on a problem and hoping someone else can point me in the right direction.
I have a console application that I wrote to retrieve data from a vendor system via a primitive Web API (IBM's flavor of XML) and write it to my system's database (via SQL calls). The app works well and does what it should. It's a bit slow, but it works, updating 16,000 products in about 3 hours. Each product can be in multiple websites and there is some business logic being applied to maintain the data in my system.
I've recently upgraded to a new computer and had to reinstall Visual Studio. I'm running 2017 Community edition. I'm an Army of One, need to be thrifty as I'm a startup and Community does everything I need it to. I don't think this is the issue, but I'm including it here just in case.
I'm trying to add some code to my console application that will send me a status email via SendGrid's API. I'm following their example here: https://sendgrid.com/docs/Integrate/Code_Examples/v2_Mail/csharp.html
I've installed the package via NuGet.
The problem is that Visual Studio is ignoring my using statements. They remain dimmed out and when I try to build it complains that I don't have the SendGrid namespace defined. When I comment out the using statements and the sendgrid code it works fine. Before I give up and send via SMTP I'd like to see if I can solve the problem and learn something.
The Sendgrid helpers using is staying active, but the others are indicating that the namespace isn't being used.
For a variety of reasons I'm not including all of my code. Here is the pertinent parts that should execute Sendgrid and send me a status email:
using System; using System.Collections.Generic; using System.Linq; using System.Xml.Linq; using System.Globalization; using System.Data.SqlClient; using System.Threading.Tasks; using Newtonsoft.Json; using System.Net.Http; using System.Net.Mail; using SendGrid; using SendGrid.Helpers.Mail; var myMessage = new SendGridMessage(); myMessage.AddTo("me@me.com"); myMessage.From("faithful@system.com"); myMessage.Subject("Vendor Inventory Complete " + howmany + "records"); myMessage.Text("Run Time: " + elapsedtime); var transportweb = new SendGrid.Web("shhh!Secret"); transportweb.DeliverAsync(myMessage).Wait();
I'm also getting a compile error "SendGridMessage .Subject cannot be used like a method. Along with a bunch of similar failures and a prompt about if I am missing a directive.
This is really frustrating as it's a pretty simple example and I've copied it exactly. What am I missing?
Last edited by a moderator: