title: Native C Dll calling C++/CLI Mixed Mode Dll - Unhandled Exception
body: <p>I have a Native C Dll that is dynamically loaded by a legacy application.  The intent of this dll is to allow overriding of application behavior based on certain application events.  I have a C# dll that contains functions that I call from the Native C dll through the mixed mode C++/CLI dll to enhance these application events.  The application using this architecture works flawlessly on Windows 2000. </p>
  
  <p>The application also runs on Windows XP but unfortunately the application crashes(Unhandled Exception) once the Native C dll is loaded at application startup.  It appears that it crashes when it is attempting to load the mixed mode dll.  I have removed all dependencies to the mixed mode dll from the Native C dll and the application boots up fine.  But once the dependency is added, the crash occurs.  The code on Windows 2000 is the same as what is used on Windows XP. I don't have access to the application code but do have access to the Native C dll code but can't get the debugger to stop as the crash occurs before intialization has completed. I suspect it is something to do with CLR initialization and OS loader differences but am not certain.  I'm looking for suggestions on how to go about resolving this. I am using VS2005 using the 2.0 Framework.  I appreciate any help you could give.</p>
  
  <p>The exception and stack trace is not real helpful:</p>
  
  <p>Unhandled exception at 0x775125f6 in MyApplication.exe: 0xC0000005: Access violation reading location 0x775125f6. </p>
  
  <pre><code>775125f6()  
  user32.dll!7e418734()   
  [Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]    
  user32.dll!7e418816()   
  user32.dll!7e428ea0()   
  user32.dll!7e42ce7c()   
  ntdll.dll!7c90e473()    
  user32.dll!7e42e389()   
  </code></pre>
  
  <p>...</p>