I have a C# method which contains code like the following:
try
{
// Do whatever
}
catch (Exception2 ex)
{
// Handle exception 1
}
catch (Exception2 ex)
{
// Handle exception 1
}
catch (Exception3 ex)
{
// Handle exception 3
}
When I try to debug it, I could place breakpoints normally. However, when one of the catch statements uses the when
keyword, like:
catch (ArgumentOutOfRangeException ex) when (ex.Message.StartsWith("Whatever message"))
no debugging symbol is loaded for that method and I cannot get the debugger to break inside it. Breakpoints inside the method are displayed like:
Any idea why this is happening? I am using VS2015 Update 3.
UPDATE: One of the comments asked me to show more code, but I literally ended up simplifying my code to the following:
using (var model = ContentInventoryModel.Create())
{
try
{
Console.WriteLine("test");
}
catch (ArgumentOutOfRangeException ex) when (ex.Message.Contains("This email group can"))
{
}
}
With this code, no symbols are not generated for the method and so I cannot put a break point, say, at Console.WriteLine
statement. By the time I remove the when keyword
, symbols get generated and I can put a break point at Console.WriteLine
statement.
It might be worth mentioning that I am debugging through ReSharper's NUnit Test Runner.