Search code examples
asp.netwcfiisvisual-studio-debugging

WCF prevent debugger breaking at DataServiceException


I throw unhandled DataServiceExceptions (they are handled by WCF automatically) to return status codes for unauthorised access etc. How do I prevent Visual Studio from breaking at these unhandled exceptions?

if (!System.Web.Security.Roles.IsUserInRole("Users"))
        {
            throw new DataServiceException((int)HttpStatusCode.Unauthorized, "You do not have access to this resource.");
        }

Solution

  • Can you add a DebuggerNonUserCode attribute

    or you could tell visual studio to ignore the exception type, as in: How to tell the debugger to ignore breaking on thrown exceptions?