0

I have it this a try/catch block, but it is not throwing any exceptions.

I can hit a breakpoint up to

email.Subject = _subject;

but after that it will not break, unless in debug mode..

public void Send()
{
    MailMessage email = new MailMessage();
    email.From = new MailAddress(From);

    foreach (string receiver in Receivers)
    {
        email.To.Add(new MailAddress(receiver));
    }

    email.Subject = _subject;
    email.Body = Body;
    var client = Client;
    client.Send(email);
}

I'm out of ideas, I appreciate any help.

EDIT - I'm not concerned about the breakpoints. I just want to figure out why this code is not working.

SOLVED

The receiver address was being changed between debug and release modes.

The address in release mode did not accept emails from addresses that are not authenticated.

  • 6
    You mean that breakpoints stop working if you run it in release mode? That's the expected behavior... – Gusman Jan 26 '17 at 23:14
  • Which try/catch block are you talking about? – Thomas Weller Jan 26 '17 at 23:28
  • Further to @Gusman, there are a ton of optimisations that get made when you compile for release. Dead code gets removed and shuffled around amongst other things, so your PDB files aren't going to match up as they do in debug mode. Related post http://stackoverflow.com/questions/367884/what-is-the-difference-between-debug-and-release-in-visual-studio – Christopher Thomas Jan 27 '17 at 01:41
  • @Gusman I'm not concerned about hitting breakpoints, it was just an observation made when trying to solve the problem. – Chandler Turner Jan 27 '17 at 15:59
  • @ThomasWeller The call to the method is contained in a try/catch block – Chandler Turner Jan 27 '17 at 16:01
  • You didn't asked that, it's only on your update, reformat your question to be more clear, just an advice. Also, are you sure the code is being hit? do you have any type of log? – Gusman Jan 27 '17 at 16:01

1 Answers1

3

Depending on the debugger, there's a setting which you need to change. Visual Studio for example asks what to do. Choosing the second option "Disable Just My Code" will consider breakpoints when possible.

Disable Just My Code

Thomas Weller
  • 55,411
  • 20
  • 125
  • 222