I’m currently working on a project that involves an .ashx page with code behind and I was trying to debug it when I came across this error. A lot of confused people out there talking about this error in different situations.
The solution to this in this in my case which may help others is in two steps
1. in the mark-up for the .ashx file make sure you specify the debug=true attribute
<%@ WebHandler Language="C#" CodeBehind="FileUpload.ashx.cs" Class="SilverlightFileUploadWeb.FileUpload" debug="true"%>
2. Then make sure that under the properties for the website part of you application has native Code debugging set to true. VS will then load the debug symbols for the .ashx ASP page and allow breakpoints in the server code.
I have to say I had to stumble around for a long time to figure this out and the solution is 90% intuition and the 90% picking through other peoples posts and yes that is 180% of my time!! The MS information on the debugging process is rank and I’ve seen so much disparity in ideas on this error that I points to (as usual) it raising it’s ugly head in different circumstances. But this is my story and now I can move on to finding out where the server side errors are. If you want to be further boggled take a look at MS’s description of what they think native code is about. It’s counter intuitive. What’s it all about MS!!