title: CoInitializeSecurity for managed application, creating a shim?
body: <p>I am currently researching the problem of setting com+ security context to: None for the managed winforms process. </p>
  
  <p>In .NET it is impossible to set CoInitializeSecurity as the first line of the code after Main, too late to do it. That method is already invoked by CLR as I understood.</p>
  
  <p>In the link below: 
  <a href="http://www.pinvoke.net/default.aspx/ole32.coinitializesecurity" rel="nofollow noreferrer">http://www.pinvoke.net/default.aspx/ole32.coinitializesecurity</a> </p>
  
  <p>It is written: </p>
  
  <blockquote>
    <p>"The workaround is to write an unmanaged "shim" that will call CoInitializeSecurity, then activate and call into managed code. You can do this via an export from a mixed-mode C++ DLL, by registering a managed component for use by COM, or by using the CLR hosting API." </p>
  </blockquote>
  
  <p>Could someone shed some light on this? How should that be written in unmanaged code (language doesn't matter)</p>
  
  <p>The managed application calls com+ server from time to time and I don't see
  any reason why I should activate the interface straightaway to pass
  the pointer to managed code?</p>