title: JIT Debugging .NET
body: <p>I have created a service using C# with Visual Studio 2010. Using .NET Framework v4.0. Running on Windows 7, 32 bit machine. The service calls into a native DLL I created. This DLL is throwing an access violation.</p>
  
  <p>I can't debug it and need help. </p>
  
  <p>I start the service and run my IDE as Administrator. The service is running under the same user account as I am logged into the machine as. I attach to the service using Managed v4.0 and Native attach code types. But when it crashes, a dialog pops up that says "An unhandled Microsoft .NET framework exception occurred" in my app. "The Just-In-Time debugger was launched without necessary security permissions. To debug this process, the Just-In-Time debugger must be run as an Administrator. Would you like to debug this process?". Even though I launched Visual Studio with "Run As Administrator". </p>
  
  <p>When I click "Yes" I get another warning "The current debugger is configured to debug code that uses Microsoft .NET Framework v1.0, 1.1, or 2.0. An unhandled exception is being thrown from .NET Framework v4.0 code". Even though I attach to the process using Managed v4.0 and Native. (I've tried just with Managed v4.0 and get same results). </p>
  
  <p>I click okay, and launch a new instance of the IDE. The IDE then displays a warning that says it is "Unable to attach to the crashing process. A debugger is already attached."</p>
  
  <p>So I try again, this time without attaching debugger hoping to get the same JIT pop-up so I can then attach after the crash, but I don't. The process just goes away or I get the usual dialog about creating a mini dump and sending it to Microsoft. </p>
  
  <p>So I tried settling for full crash dump.</p>
  
  <p>I followed the instructions at <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/bb787181(v=vs.85).aspx" rel="nofollow noreferrer" title="Collecting User-Mode Dumps">Collecting User-Mode Dumps</a> to create full dumps. I'll watch as WerFault.exe starts in task manager and watch the file get created and when WerFault it's done, either the crash dump disappears or stack trace is missing native code. </p>
  
  <p>I seem to have similar problems debugging .NET processes from time to time. How can I reliably configure my computer so I can get JIT debugging? </p>