当我编写c ++程序(如B3DTest.exe)时,依赖于第三方dll(例如B3DViews.dll)(供应商是小公司)。我编写的程序非常简单,只是为了测试dll中的一个函数。当我启动我的程序时(所需的头文件,.lib文件和.dll文件被链接)。我在下面遇到了这个问题。
The application failed to initialize properly (0xc0150002). Click on OK to terminate
the application.
我发现程序在进入我的main函数之前退出。 vs2008 IDE的输出是
LDR: LdrpWalkImportDescriptor() failed to probe e:\tlh1987\vs2008projects\B3DTest\Debug\B3DViews.dll
for its manifest, ntstatus 0xc0150002
我将程序和dll放在另一台目标计算机上,它运行正常。所以我认为我的电脑一定有问题。我搜索了事件日志,并在下面说了三个事件
EventID: 32
Description: Dependent Assembly Microsoft.VC80.CRT could not be found and Last Error was The referenced
assembly is not installed on your system.
EventID: 59
Description: Resolve Partial Assembly failed for Microsoft.VC80.CRT. Reference error message: The
referenced assembly is not installed on your system.
EventID: 59
Description: Generate Activation Context failed for Generate Activation Context
E:\tlh1987\vs2008projects\B3DTest\Debug\B3DViews.dll. Reference error message: The operation completed
successfully.
我通过安装Microsoft Visual C++ 2005 Redistributable Package
和Microsoft Visual C++ 2005 SP1 Redistributable Package (x86).
来搜索互联网,发现有人解决了类似的问题
我下载了两个文件并安装了它。但是,它无法工作!
在互联网上的另一个解决方案是放置Microsoft.VC80.CRT文件夹的文件,其中包括3个dll和Microsoft.VC80.MFC文件夹(也包括4个dll),最后是B3DTest.exe目录中的对应清单文件(我的程序) 。但是,它仍然无法正常工作!但有些内容已经改变了event log
,其中只有1 event error
,如下所示:
EventID: 59
Description: Generate Activation Context failed for Generate Activation Context
E:\tlh1987\vs2008projects\B3DTest\Debug\B3DViews.dll. Reference error message: The operation completed
successfully.
有人告诉我,可能是VC80.CRT的版本,我计算机中的VC80.MFC与B3DViews.dll
(由供应商分发)中的版本号不匹配。然后我用emacs.exe打开B3DViews.dll
并搜索附加到dll的清单。它在下面说:
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC80.CRT" version="8.0.50727.6195"
processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC80.MFC" version="8.0.50727.6195"
processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC80.CRT" version="8.0.50608.0"
processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC80.MFC" version="8.0.50608.0"
processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
</dependentAssembly>
</dependency>
</assembly>
版本号让我感到困惑。它是如何8.0.50727.6195
以及8.0.50608.0
它认为它应该是一个版本号(不是上面显示的两个)。我找到了Microsoft.VC80.CRT dll和Microsoft.VC80.MFC dll以及相应的清单文件(C:\ Windows \ WinSxS中的所有版本号都是8.0.50727.6195
并将它放在dir中相同作为B3DTest.exe
(我的程序)。它也无法工作。
为了弄清楚问题。我使用Dependency Walker for Win32 (x86)
来分析我的程序,即B3DTest.exe
。它在下面说:
Started "B3DTEST.EXE" (process 0x680) at address 0x00400000. Successfully hooked module.
Loaded "NTDLL.DLL" at address 0x7C920000. Successfully hooked module.
Loaded "KERNEL32.DLL" at address 0x7C800000. Successfully hooked module.
DllMain(0x7C920000, DLL_PROCESS_ATTACH, 0x00000000) in "NTDLL.DLL" called.
DllMain(0x7C920000, DLL_PROCESS_ATTACH, 0x00000000) in "NTDLL.DLL" returned 1 (0x1).
DllMain(0x7C800000, DLL_PROCESS_ATTACH, 0x00000000) in "KERNEL32.DLL" called.
DllMain(0x7C800000, DLL_PROCESS_ATTACH, 0x00000000) in "KERNEL32.DLL" returned 1 (0x1).
Injected "DEPENDS.DLL" at address 0x08370000.
DllMain(0x08370000, DLL_PROCESS_ATTACH, 0x00000000) in "DEPENDS.DLL" called.
DllMain(0x08370000, DLL_PROCESS_ATTACH, 0x00000000) in "DEPENDS.DLL" returned 1 (0x1).
Loaded "B3DVIEWS.DLL" at address 0x10000000. Successfully hooked module.
LDR: LdrpWalkImportDescriptor() failed to probe e:\tlh1987\vs2008projects\b3dtest\debug\B3DViews.dll
for its manifest, ntstatus 0xc0150002
First chance exception 0xC0150002 (Unknown) occurred in "NTDLL.DLL" at address 0x7C9873BE.
**Second chance exception 0xC0150002 (Unknown) occurred in "NTDLL.DLL" at address 0x7C9873BE.**
Exited "B3DTEST.EXE" (process 0x680) with code -1072365566 (0xC0150002).
它让我发疯了。我不想弄清楚。任何帮助将不胜感激!
这(http://www.codeguru.com/forum/showthread.php?t=408061)可能有助于解决问题。但是通过阅读我无法弄明白。
我的系统是windows xp sp3,我使用的是VS2008。我没有安装VS2005。
答案 0 :(得分:1)
我想出来了。借助此Q&amp; A
http://social.msdn.microsoft.com/Forums/nb-NO/vssetup/thread/fa559cb7-eabc-4f41-a3bc-84ed7ae089fc
首先,我卸载了所有Microsoft Visual C++ 2005 Redistributable Package
第二,我直接安装了Microsoft Visual C++ 2005 SP1 Redistributable Package (x86)
。它也没用,但是当我安装
Visual C++ 2005 Service Pack 1 Redistributable Package MFC Security Update
它只是有效。似乎更新del旧版Microsoft Visual C++ 2005 Redistributable Package
,然后使新版本(sp1 one)工作。
答案 1 :(得分:1)
首先,我卸载了所有Microsoft Visual C ++ 2005 Redistributable Package 第二,我直接安装了Microsoft Visual C ++ 2005 SP1可再发行组件包(x86)。它也没用,但是当我安装
时Visual C ++ 2005 Service Pack 1可再发行软件包MFC安全更新
它只是起作用
答案 2 :(得分:1)
0xC0150002L
是STATUS_SXS_CANT_GEN_ACTCTX
。用于调试激活上下文问题的工具是SxsTrace
。试试这个:
touch program.exe
SxsTrace Trace -logfile:SxsTrace.etl
[run program.exe]
SxsTrace Parse -logfile:SxsTrace.etl -outfile:SxsTrace.txt
SxsTrace.txt将包含引用但无法找到的程序集的名称。