Throw exception gives same message all the time
I have a try and catch in my Main.cs
try
{
}
catch(exception e)
{
Console.WriteLine(e.Message)
}
In a other class i have:
if (....)
{
开发者_开发技巧 //input
}
else
{
throw new Exception("Custom Error Message1"}
}
In a other class i have a similar situation, but insteed the message is different here. When a error occurs in the 2nd class the same message from the one above displays, what exactly is the cause of this and what could prove to be a solution?
Thanks in advance.
Have you examined the stack trace? That might tell you something, n'est-ce-pas?
In Visual Studio, go to Debug-Exceptions and set Common Language Runtime exceptions to break when THROWN. Now run your program in debug and you'll see which exception is actually being thrown and can examine the call stack.
精彩评论