Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack – C# : Resolved

Sometimes while executing following code you may get error “Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack”

string url = "myURL.aspx?UserId=" + this.UserId.ToString();
Response.Redirect(url);

It is because you are redirecting the page without execution gets complete. so solution is either you Perform a search for Response.Redirect() and either make the second parameter endResponse = false, or Temporarily disable the redirect call.





Try following code. It will work.

Response.Redirect(url,false);

False indicate : Indicate execution of current page should not be terminated.

Hope it helps.

5 Responses to Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack – C# : Resolved

  1. elurserange says:

    Oh my goodness! an impressive article dude. Thank you Nonetheless I’m experiencing issue with ur rss . Don’t know why Unable to subscribe to it. Is there everyone acquiring identical rss difficulty? Anybody who knows kindly respond. Thnkx

  2. ibbc group says:

    It is perfect time to make some plans for the future and it is time to
    be happy. I have read this post and if I could I want to suggest you few interesting things or tips.
    Maybe you can write next articles referring
    to this article. I wish to read more things about it!

  3. Kenneth says:

    Hmm is anyone else having problems with the images on this blog loading?
    I’m trying to find out if its a problem on my end or if it’s the blog.
    Any feedback would be greatly appreciated.

  4. Hello, always i used to check weblog posts here in the early hours in the daylight, as i like to learn more and more.

  5. Pretty nice post. I just stumbled upon your weblog and wished to say that I have really
    enjoyed browsing your blog posts. After all I will
    be subscribing to your feed and I hope you write again very soon!

Leave a Reply

Your email address will not be published.