启动依赖第三方dll的程序时程序初始化失败(0xc0150002)
当我编写C++程序(例如B3DTest.exe)时,依赖于第三方dll(例如B3DViews.dll)(供应商是小公司)。我写的程序很简单,只是为了测试dll中的一个函数。当我启动程序时(链接所需的头文件、.lib 文件和 .dll 文件)。我遇到了下面的问题。
The application failed to initialize properly (0xc0150002). Click on OK to terminate
the application.
我发现程序在进入我的主函数之前退出。 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 解决了类似的问题可再发行软件包 (x86)。
我下载了这两个文件并安装了它。然而,却行不通! 互联网上的另一个解决方案是将包含3个dll的Microsoft.VC80.CRT文件夹的文件和Microsoft.VC80.MFC文件夹(还包含4个dll)的文件,最后将相应的清单文件放在B3DTest.exe(我的程序)的目录中。然而,还是没有成功!但是事件日志
发生了一些变化,其中只有 1 个事件错误
,如下所示:
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
它认为应该是一个版本号(而不是上面显示的两个)。我在 C:\Windows\WinSxS 中找到了 Microsoft.VC80.CRT dll 和 Microsoft.VC80.MFC dll 以及相应的清单文件(所有版本号都是 8.0.50727.6195
)并将其放入在与 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。
When I write a c++ program (such as B3DTest.exe) depend on a third party dll(such B3DViews.dll) (the vendor is small company). The program that I wrote is very simple just to test one function in the dll. When I start my program (the needed header file, .lib files and .dll file are linked). I come across the problem below.
The application failed to initialize properly (0xc0150002). Click on OK to terminate
the application.
I find out that the program exit before enter my main function. the out put of the vs2008 IDE is
LDR: LdrpWalkImportDescriptor() failed to probe e:\tlh1987\vs2008projects\B3DTest\Debug\B3DViews.dll
for its manifest, ntstatus 0xc0150002
I put the program and the dll in an other target computer and it works fine. So I think it must be something wrong with my computer. I searched the event log and it says below for three event
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.
I search The Internet to find out that someone fix a similar problem by installing Microsoft Visual C++ 2005 Redistributable Package
and the Microsoft Visual C++ 2005 SP1 Redistributable Package (x86).
I download the two files and installed it. However, it couldn't work!
Another solution on the internet is Put the files of Microsoft.VC80.CRT folder which include 3 dll and Microsoft.VC80.MFC folder (also include 4 dll) and finally the correspond manifest files in the dir of B3DTest.exe (my program). However, It still didn't work! But something has changed the event log
where there is only 1 event error
which says below:
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.
Somebody told me that may be the version of the VC80.CRT and the VC80.MFC in my computer didn't match the version number in the B3DViews.dll
(which is distributed by the vendor). Then I open the B3DViews.dll
with emacs.exe and search the manifest attached to the dll. It says below:
<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>
the version number made me confused. How can it is 8.0.50727.6195
as well as 8.0.50608.0
It think it should be one version number (not two as showed above). I find the Microsoft.VC80.CRT dlls and the Microsoft.VC80.MFC dlls and also the correspond manifest files (all the version numbers is 8.0.50727.6195
in the C:\Windows\WinSxS and put it in the dir the same as B3DTest.exe
(my program). It couldn't work either.
In order to figure out the problem. I used the Dependency Walker for Win32 (x86)
to profile my program i.e. B3DTest.exe
. It says below:
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).
It drives me crazy. I wan't to figure it out. any help will appreciated!
This(http://www.codeguru.com/forum/showthread.php?t=408061) may help to the problem. But I can not figure it out by reading it.
my system is windows xp sp3 and I using VS2008. I didn't install VS2005.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我以某种方式弄清楚了。在此问答
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 安全更新
它可以正常工作。看来更新删除了旧版本的
Microsoft Visual C++ 2005 Redistributable Package
,然后使新版本(sp1 版本)能够工作。I figure it out somehow. with the help of this Q&A
http://social.msdn.microsoft.com/Forums/nb-NO/vssetup/thread/fa559cb7-eabc-4f41-a3bc-84ed7ae089fc
first, I uninstalled all the
Microsoft Visual C++ 2005 Redistributable Package
second, I installed
Microsoft Visual C++ 2005 SP1 Redistributable Package (x86)
directly. It didn't work either, but when I installedVisual C++ 2005 Service Pack 1 Redistributable Package MFC Security Update
It just works. It seems that the Update del the old version of
Microsoft Visual C++ 2005 Redistributable Package
, then make the new one (the sp1 one) to work.首先,我卸载了所有 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
时它就起作用了
First, I uninstalled all the Microsoft Visual C++ 2005 Redistributable Package
second, I installed Microsoft Visual C++ 2005 SP1 Redistributable Package (x86) directly. It didn't work either, but when I installed
Visual C++ 2005 Service Pack 1 Redistributable Package MFC Security Update
It just works
0xC0150002L
是STATUS_SXS_CANT_GEN_ACTCTX
。用于调试激活上下文问题的工具是SxsTrace
。试试这个:SxsTrace.txt 将包含引用但无法找到的程序集的名称。
0xC0150002L
isSTATUS_SXS_CANT_GEN_ACTCTX
. The tool for debugging activation context issues isSxsTrace
. Try this:SxsTrace.txt will contain the name of the assembly that is referenced and can't be found.