When invoking .NET CLR from within C++, an error is returned
<p>I am calling a .NET assembly from C++. </p>

<p>This works perfectly for any test .NET 4.0 projects that I call. </p>

<p>However, when calling a large project with 20 sub-assemblies, it fails with the error below:</p>

<pre><code>Failed to execute assembly: 0x80004003. GetLastError=126. dwReturn=1.
</code></pre>

<p>Here is the C++ code that generates the error:</p>

<pre><code>DWORD dwReturn;
hr = pCLR-&gt;ExecuteInDefaultAppDomain(szApplication, szEntryType, szEntryMethod, szParameter, &amp;dwReturn);
if (FAILED(hr))
{
    // Fails if I try the production assembly, with 20 subassemblies.
    printf("    Failed to execute assembly: 0x%X. GetLastError=%d. dwReturn=%d.\n", hr, GetLastError(), dwReturn);
}
else
{
    // Works 100% if I plug in a small toy assembly in .NET 4.0.
    wprintf(L"    Assembly returned: %d\n", dwReturn);
}
</code></pre>

<h2>Environment</h2>

<ul>
<li>Visual Studio 2010 SP1.</li>
<li>C++ for the code above.</li>
<li>.NET 4.0 for the target assembly.</li>
</ul>
