BUG: Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.

In .NET 2.0 i had a serious bug and screwed my head, for me the below code looks fine,

        try{

if (retVal == 0) Response.Redirect("Success.aspx?evt=0");

if (retVal == -2) //Email-Id is already present Response.Redirect("Success.aspx?evt=1");

if (retVal == -1) //Some error occured Response.Redirect("Success.aspx?evt=2");

} catch(Exception error) { Response.Redirect("Success.aspx?evt=2"); } finally{}

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.

I was stunned by seeing once after i commented the try catch block, it worked fine. Guys, any idea about this?

This article is part of the GWB Archives. Original Author: Vadivel Kumar

New on Geeks with Blogs