title: IIS8 The Just-In-Time debugger was launched without necessary security permissions
body: <p>Windows Server 2012 64 bit
  IIS8
  ASP.NET Framework 4</p>
  
  <p>Trying to run an unmanaged DLL from my aspx page</p>
  
  <p>Executing the DLL Function call gives:</p>
  
  <p>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?</p>
  
  <p>There is no debugger that I know of on the web server, trying to launch it gives errors.</p>
  
  <ol>
  <li>Why is my call to my DLL crashing my aspnet worker process?</li>
  <li>How can I tell IIS8 there is no debugger?</li>
  </ol>
  
  <p>I have googled this extensively, and all the help seems to be about Visual Studio, not IIS.  There is no Visual Studio on the web sever.</p>
  
  <p>Here is the offending code.</p>
  
  <pre><code>private string regname = "";
  private string fingerprint = "";
  private string unlockingcode = "";
  
  /// &lt;summary&gt;
  /// called from page_load
  /// &lt;/summary&gt;
  private void CreateUnlockingCode()
  {
      UInt32 lfp;
      string sfp = fingerprint.Remove(4, 1);
      lfp = Convert.ToUInt32(sfp, 16);
  
      string bindir = Server.MapPath(@"~/bin/CodeGen64.dll");  //full path to the DLL "P:\\AFI2013\\bin\\CodeGen64.dll"               
  
      IntPtr pDll = NativeMethods.LoadLibrary(bindir);  //attempt to load the library
      try
      {
          IntPtr pAddressOfFunctionToCall = NativeMethods.GetProcAddress(pDll, "CreateCode2A");
          CreateCode2 createCode2 = (CreateCode2)Marshal.GetDelegateForFunctionPointer(
              pAddressOfFunctionToCall,
              typeof(CreateCode2));
  
          //THIS LINE CRASHES THE ASPNET WORKER PROCESS
          unlockingcode = createCode2(1, regname, encrypt_template, lfp, (UInt16)0, (UInt16)0, (UInt16)0, (UInt16)0, (UInt16)0);
      }
      finally
      {
          bool result = NativeMethods.FreeLibrary(pDll);
      }
  }
  </code></pre>
  
  <p>And here is the Error from the Event Viewer.</p>
  
  <pre><code>Log Name:      Application
  Source:        Application Error
  Date:          7/10/2013 11:34:30 AM
  Event ID:      1000
  Task Category: (100)
  Level:         Error
  Keywords:      Classic
  User:          N/A
  Computer:      owl.INT.local
  Description:
  Faulting application name: w3wp.exe, version: 8.0.9200.16384, time stamp: 0x50108835
  Faulting module name: ntdll.dll, version: 6.2.9200.16579, time stamp: 0x51637f77
  Exception code: 0xc0000374
  Fault offset: 0x00000000000ebd59
  Faulting process id: 0x2608
  Faulting application start time: 0x01ce7d9c1d409343
  Faulting application path: c:\windows\system32\inetsrv\w3wp.exe
  Faulting module path: C:\Windows\SYSTEM32\ntdll.dll
  Report Id: 5b36e881-e98f-11e2-9406-000c2908dae4
  Faulting package full name: 
  Faulting package-relative application ID: 
  Event Xml:
  &lt;Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"&gt;
    &lt;System&gt;
      &lt;Provider Name="Application Error" /&gt;
      &lt;EventID Qualifiers="0"&gt;1000&lt;/EventID&gt;
      &lt;Level&gt;2&lt;/Level&gt;
      &lt;Task&gt;100&lt;/Task&gt;
      &lt;Keywords&gt;0x80000000000000&lt;/Keywords&gt;
      &lt;TimeCreated SystemTime="2013-07-10T18:34:30.000000000Z" /&gt;
      &lt;EventRecordID&gt;54586&lt;/EventRecordID&gt;
      &lt;Channel&gt;Application&lt;/Channel&gt;
      &lt;Computer&gt;owl.INT.local&lt;/Computer&gt;
      &lt;Security /&gt;
    &lt;/System&gt;
    &lt;EventData&gt;
      &lt;Data&gt;w3wp.exe&lt;/Data&gt;
      &lt;Data&gt;8.0.9200.16384&lt;/Data&gt;
      &lt;Data&gt;50108835&lt;/Data&gt;
      &lt;Data&gt;ntdll.dll&lt;/Data&gt;
      &lt;Data&gt;6.2.9200.16579&lt;/Data&gt;
      &lt;Data&gt;51637f77&lt;/Data&gt;
      &lt;Data&gt;c0000374&lt;/Data&gt;
      &lt;Data&gt;00000000000ebd59&lt;/Data&gt;
      &lt;Data&gt;2608&lt;/Data&gt;
      &lt;Data&gt;01ce7d9c1d409343&lt;/Data&gt;
      &lt;Data&gt;c:\windows\system32\inetsrv\w3wp.exe&lt;/Data&gt;
      &lt;Data&gt;C:\Windows\SYSTEM32\ntdll.dll&lt;/Data&gt;
      &lt;Data&gt;5b36e881-e98f-11e2-9406-000c2908dae4&lt;/Data&gt;
      &lt;Data&gt;
      &lt;/Data&gt;
      &lt;Data&gt;
      &lt;/Data&gt;
    &lt;/EventData&gt;
  &lt;/Event&gt;
  </code></pre>