An unhandled exception occurred during the execution
I have handling the exception in my code as below, but still get error :
catch (Exception e)
{
throw new Exception(e.Message);
}
And here is the error :
An unhandled exception occurred du开发者_运维知识库ring the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception: Object reference not set to an instance of an object.
It sounds more like you are accessing a object that has been released/ or a null object.
If you are handling your exception in this way (only retrowing it) than don't catch exeptions on this level. Catch Exceptions in the method that's calling this function (Or where you want to handle your exception) and do your handling/showing the message overthere.
You probably don't have another try/catch block in the calling method which is causing the unhandled exception.
You still get an error because you are throwing a new exception in the catch block.
From a catch block you are throwing a new excpetion which is creating a problem try to remove throw new exception or add a new parent try catch block
IN the Catch block instead you use the following code to display an exception u r again throwing the Exception, remove it and try again. Hope it helps.
精彩评论