BUG: Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.
I'm using the Enterprise edition of VS 2005. When I debug my project an exception is raised - 'Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack'. I can't find anything about this on-line.
The Code look like:
catch (Exception ex)
throw ex ;
I sware there is no bug in this code, when tried to execute this code it creates an exception
Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.
This bug screwed my head. but finally i found solution.
Cause of problem: The Response.End method ends the page execution and shifts the execution to theApplication_EndRequest event in the application's event pipeline. The line of code that followsResponse.End is not executed.This problem occurs in the Response.Redirect and Server.Transfer methods because both methods call Response.End internally.
- For Response.End, call theHttpContext.Current.ApplicationInstance.CompleteRequest method instead ofResponse.End to bypass the code execution to the Application_EndRequest event.
- For Response.Redirect, use an overload, Response.Redirect(String url, bool endResponse) that passes false for the endResponse parameter to suppress the internal call to Response.End. For example:
If you use this workaround, the code that follows Response.Redirect is executed.
- For Server.Transfer, use the Server.Execute method instead.
This solution really helps me.
Is the above link useful to you? Let us know your feedback, it will help us to improve our posting(s). or You can send your feedback linkOblast.