Why doesn't Visual Studio show an exception message when my exception occurs in a static constructor
Posted
by Tim Goodman
on Stack Overflow
See other posts from Stack Overflow
or by Tim Goodman
Published on 2010-03-25T21:01:09Z
Indexed on
2010/03/25
21:03 UTC
Read the original article
Hit count: 447
I'm running this C# code in Visual Studio in debug mode:
public class MyHandlerFactory : IHttpHandlerFactory
{
private static Dictionary<string, bool> myDictionary = new Dictionary<string, bool>();
static MyHandlerFactory()
{
myDictionary.Add("someKey",true);
myDictionary.Add("someKey",true); // fails due to duplicate key
}
}
Outside of the static constructor, when I get to the line with the error Visual Studio highlights it and pops up a message about the exception. But in the static constructor I get no such message. I am stepping through line-by-line, so I know that I'm getting to that line and no further.
Why is this?
(I have no idea if that fact that my class implements IHttpHandlerFactory matters, but I included it just in case.)
This is VS2005, .Net 2.0
© Stack Overflow or respective owner