Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack
" Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack" - This is one of the common error we see in forum where people request solution for it.
Below is a small explanation and resolution to resolve this issue,
This error normally occurs when we use
Response.Redirect or Server.Transfer or Response.End in your
code before completing the actual process the page was
doing.
In this case what you have to do is
In place of Response.End you have to use
HttpContext.Current.ApplicationInstance.CompleteRequest
and in place of Response.Redirect, use
the Response.Redirect ("Paganame.aspx", false);
and in place of Server.Transfer, use the
Server.Execute method
There is also a KB article related to this issue,
http://support.microsoft.com/kb/312629/EN-US/