sendgrid / sendgrid-csharp

The Official Twilio SendGrid C#, .NetStandard, .NetCore API Library
https://sendgrid.com
MIT License
1.08k stars 585 forks source link

SendGridClient.cs not found - occurs on statement: var client = new SendGridClient(apiKey); } #878

Closed dhaverka closed 5 years ago

dhaverka commented 5 years ago

Issue Summary

I receive the SendGridClient.cs not found error.

It occurs on statement: var client = new SendGridClient(apiKey);

I have a valid value in apikey

thinkingserious commented 5 years ago

Hello @dhaverka,

How did you install the library and what version did you install?

Thanks!

With Best Regards,

Elmer

dhaverka commented 5 years ago

I used the Visual Studio Manage Nuget Console, and I searched for Sendgrid. I chose to install it and it installed 9.11.0

dhaverka commented 5 years ago

i uninstalled and cleared the nuget cache, and went into package manager console and typed install-package sendgrid. It stated install successful. So, I retried my program, same error: SendGridClient.cs not found. source search information: Locating source for 'C:\Users\elmer\Documents\GitHub\sendgrid-csharp\src\SendGrid\SendGridClient.cs'. Checksum: SHA1 {f9 b7 9e ee aa d3 b2 22 56 e5 ff 61 4e d1 c7 30 bc fa d8 56} The file 'C:\Users\elmer\Documents\GitHub\sendgrid-csharp\src\SendGrid\SendGridClient.cs' does not exist. Looking in script documents for 'C:\Users\elmer\Documents\GitHub\sendgrid-csharp\src\SendGrid\SendGridClient.cs'... Looking in the Edit-and-Continue directory 'C:\Users\daleh\Documents\Visual Studio 2017\Projects\SpecialProducts\enc_temp_folder\'... The file with the matching checksum was not found in the Edit-and-Continue directory. Looking in the projects for 'C:\Users\elmer\Documents\GitHub\sendgrid-csharp\src\SendGrid\SendGridClient.cs'. The file was not found in a project. Searching for documents embedded in the symbol file. An embedded document was not found. The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: C:\Users\elmer\Documents\GitHub\sendgrid-csharp\src\SendGrid\SendGridClient.cs. The debugger could not locate the source file 'C:\Users\elmer\Documents\GitHub\sendgrid-csharp\src\SendGrid\SendGridClient.cs'.

dhaverka commented 5 years ago

going home for the day, I'll sign on at home to see if there's response yet this evening.

thinkingserious commented 5 years ago

Hello @dhaverka,

I have just tried to reproduce on Visual Studio 2017 in Windows 10. I did not receive the error. Could you please provide further detail on your programming environment?

Here is the code I used: https://github.com/sendgrid/sendgrid-csharp#hello-email

With Best Regards,

Elmer

dhaverka commented 5 years ago

4.61, mvc program with controllers, this is in a common.cs - my twilio routines for SMS and fax were removed to send this. I will try your example as a standalone project later. This program errors on the var client statement

using System; using System.Collections.Generic; using System.Linq; using System.Web; using SpecialProducts.Models; using System.Threading.Tasks; using System.Runtime.InteropServices; using Twilio; using Twilio.Types; using System.Web.Mvc; using Twilio.AspNet.Common; using Twilio.AspNet.Mvc; using Twilio.TwiML; using Twilio.Rest.Api.V2010.Account; using Twilio.Rest.Fax.V1; using SendGrid; using SendGrid.Helpers.Mail;

namespace Dale {

public class Common
{
    private SpecialProductsEntities1 db = new SpecialProductsEntities1();

    public string SendEmail()
    {
        Execute().Wait();
        return "Email Completed";
    }

    static async Task Execute()
    {

        var apiKey = System.Environment.GetEnvironmentVariable("SENDGRID_API_KEY");
        try
        {
            var client = new SendGridClient(apiKey);
        }
        catch(Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
        var msg = new SendGridMessage()
        {
            From = new EmailAddress("example@azure.com", "dale"),
            Subject = "Hello World from the SendGrid CSharp SDK!",
            PlainTextContent = "Hello, Email!",
            HtmlContent = "<strong>Hello, Email!</strong>"
        };
        msg.AddTo(new EmailAddress("dale@xyz.com", "Dale"));
        var response = await client.SendEmailAsync(msg);
    }

}

}

dhaverka commented 5 years ago

Hi, I figured out when it happens. If you set the break point on the var client = new statement and then step in the debugger it blows up. If you don't set a first break point until the var msg statement, it doesn't blow up. Evidently the debugger loses track of where the code lies. In non debug mode this will not be a problem.

dhaverka commented 5 years ago

I will think its typical behavior not to use the debugger to step that statement. So I will close the ticket. Thanks for being so willing to help so quickly.

dhaverka commented 5 years ago

I will think its typical behavior not to use the debugger to step that statement. So I will close the ticket. Thanks for being so willing to help so quickly.