Exception: Unable to evaluate expression…

I was working with the following code, the tail end of code which allows the user to download a file:

Response.ContentType = "text/plain";
Response.AddHeader("Content-Disposition", "attachment;filename=" + FileName + ".dat");
Response.Buffer = true;
catch (Exception e)
 // Stuff

While running through this code, I received and exception at the Response.End line:

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

Luckily, I ran cross a very useful post on the ASP.NET forums which pointed to the exact problem. I took out the try-catch block and that solved the issue.

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: