i got this exception when i done the code given below..
“Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.”
–code–
try
{
if (retVal == 0)
Response.Redirect("Success.aspx");
}
catch(Exception error)
{
Response.Redirect("errorpage.aspx");
}
finally{
}
from searching in net i found it to be a bug and if its success then we should end response… ie ” Response.Redirect(“Success.aspx”, false); “.it works fine.. is this a good method or there is any other efficient method to handle this exception please help….
Are you sure that it’s an Exception? What type of exception is it?
It looks more like you have used ‘Break’ in the debugger and it cannot evaluate a watch or expression because it’s busy running a line of code or non-managed call.
Try pressing F10 or F11 to step to the next line of managed code then looking at the expression again.
Using a breakpoint should also work.
If that doesn’t solve it, please post a comment and I will try to respond or be more specific.
This is probably what you are seeing:
Also, Response.Redirect will always throw a ThreadAbortException, see here:
To ensure that no more code gets executed, and the next code that will be run is in the context of generating the next page.
You could do this instead:
Hope that helps!