我正在从 C++ 调用 .NET 程序集。
这对于我调用的任何测试 .NET 4.0 项目都非常有效。
但是,当调用具有 20 个子程序集的大型项目时,它会失败并出现以下错误:
Failed to execute assembly: 0x80004003. GetLastError=126. dwReturn=1.
这是生成错误的 C++ 代码:
DWORD dwReturn;
hr = pCLR->ExecuteInDefaultAppDomain(szApplication, szEntryType, szEntryMethod, szParameter, &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);
}
环境
- 视觉工作室 2010 SP1。
- 上面代码的 C++。
- .NET 4.0 用于目标程序集。