title: WPF application shows managed has exited with code -1073740771 (0xc000041d) in InitializeComponent call
body: <p>When I launch my WPF application and when it goes to <code>InitializeComponent</code> function call of one user control, it silently quits and only leaves one message in the output window saying Managed (v4.0.30319)' has exited with code <code>-1073740771</code> (<code>0xc000041d</code>). When I say "silently", I mean there is no exception is caught even if I wrap this <code>InitializeComponent</code> call with a <code>try</code>-<code>catch</code> block (that's how I normally find where the problem is)</p>
  
  <p>Here is what I did: in this application project we need to use a reference Microsoft.Office.Interop.Owc.dll, with version number 10.0.4504.0. Since it is an interop library, when I added this reference in VS2012, it automatically sets the property <code>Embedded Interop Types</code> as true, which I assume means it will not keep an individual dll in the output folder but instead embed this library into the main output (at least this is how it seems in our other references, for example, Microsoft.Office.Interop.Outlook.dll). However, when I launch the project, it throws an <code>XamlParseException</code> saying:</p>
  
  <blockquote>
    <p>"Could not load file or assembly 'Microsoft.Office.Interop.Owc, Version=10.0.4504.0,
    Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system
    cannot find the file specified.":"Microsoft.Office.Interop.Owc, Version=10.0.4504.0,
    Culture=neutral, PublicKeyToken=31bf3856ad364e35""</p>
  </blockquote>
  
  <p>It seems that the reference was not embedded(or the version is not currect. But I verified that the reference version is indeed 10.0.4504.0)</p>
  
  <p>Next I copied this dll directly to the output folder <code>bin\Debug\</code>, to make sure that it can find this library. This time the exception is not thrown, but the whole application just silently quits as I described in the beginning. I tried to google the code <code>-1073740771</code> (<code>0xc000041d</code>) but there is no article about it. I tried to set the <code>Embedded Interop Types</code> to true/false but the problem is the same.</p>
  
  <p>UPDATE:</p>
  
  <p>I'd like to add more description here. As mentioned above, the problematic library is OWC(Office Web Component)10. I followed this link to make OWC work with VB.NET desktop application: <a href="http://support.microsoft.com/kb/328275/EN-US" rel="nofollow">HOW TO: Handle Events for the Office Web Components in Visual Studio .NET</a>. But this official article is so old so I had to make a lot of changes to compile the wrapper dll(mainly because of namespace mismatch). Then when I add the reference to the actual interop library Microsoft.Office.Interop.Owc, if I follow the default setting and let the Embedded Interop Types as True, at runtime it will complain (throw a <code>XamlParseException</code>) that the assembly cannot be loaded (see description above). What the hell? I thought make it as "embedded" would guarantee this library will be found. Then I copy this dll to the output folder, then I have this silently quit problem. But it might be worth mentioning that this time the output window shows the <code>Microsoft.Office.Interop.Owc.dll</code> is indeed loaded. Actually it is the last message before the <code>managed has exited</code> message. So it must still relate to this library.</p>
  
  <p>All of this only happens with OWC10. There is actually a similar way to do that in OWC11(the latest, but unfortunately still pretty old version since it came with Office2003): <a href="http://support.microsoft.com/kb/823982" rel="nofollow">HOW TO: Handle Events for the Office 2003 Web Components in Visual Studio .NET</a>. But it actually works and the control is displayed on my application. It is because of some other reason that I wanted to try OWC10 instead of OWC11</p>