当启动依赖第三方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.

我发现在进入main函数之前程序已经退出了。vs2008 IDE的输出是

LDR: LdrpWalkImportDescriptor() failed to probe e:tlh1987vs2008projectsB3DTestDebugB3DViews.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:tlh1987vs2008projectsB3DTestDebugB3DViews.dll. Reference error message: The operation completed
successfully.

我搜索互联网,发现有人通过安装Microsoft Visual C++ 2005 Redistributable PackageMicrosoft Visual C++ 2005 SP1 Redistributable Package (x86).来解决类似的问题
我下载了两个文件并安装了它。然而,这行不通!另一个解决方案是在互联网上放微软。vc80的文件。CRT文件夹,其中包括3dll和Microsoft.VC80。MFC文件夹(也包括4个dll),最后对应的manifest文件在B3DTest.exe(我的程序)的目录下。然而,它仍然不起作用!但是有些东西改变了event log,只有一个event error,下面写着:

EventID: 59
Description: Generate Activation Context failed for Generate Activation Context
E:tlh1987vs2008projectsB3DTestDebugB3DViews.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.61958.0.50608.0,它认为它应该是一个版本号(不是上面显示的两个)。我找到了微软vc80。CRT显示器和微软vc80。MFC dll和相应的清单文件(所有版本号都是C:WindowsWinSxS中的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:tlh1987vs2008projectsb3dtestdebugB3DViews.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.

我怎么就明白了。在这个问题的帮助下

http://social.msdn.microsoft.com/forums/nb - no/vssetup/thread/fa559cb7 eabc - 4 - f41 a3bc - 84 ed7ae089fc

首先,我卸载了所有的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

它只是工作。似乎Update删除了旧版本的Microsoft Visual C++ 2005 Redistributable Package,然后使新版本(sp1版本)工作。

首先,我卸载了所有的Microsoft Visual c++ 2005可重新分发包第二,我直接安装了Microsoft Visual c++ 2005 SP1 Redistributable Package (x86)。它也不工作,但当我安装

Visual c++ 2005 Service Pack 1 Redistributable Package MFC Security Update

它只是工作

0xC0150002LSTATUS_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将包含被引用但无法找到的程序集的名称。

最新更新