1

当我编写一个 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.

我在 Internet 上搜索,发现有人通过安装解决了类似的问题,Microsoft Visual C++ 2005 Redistributable PackageMicrosoft 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(由供应商分发)中的版本号。然后我B3DViews.dll用 emacs.exe 打开并搜索附加到 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认为它应该是一个版本号(不是上面显示的两个)。我找到了 Microsoft.VC80.CRT dll 和 Microsoft.VC80.MFC dll 以及相应的清单文件(所有版本号都在 C:\Windows\WinSxS 中并将其放在与(我的程序)8.0.50727.6195相同的目录中B3DTest.exe.它也不起作用.为了找出问题.我用Dependency Walker for Win32 (x86)来分析我的程序 ie 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。

4

3 回答 3

1

我以某种方式弄清楚了。在这个问答的帮助下

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 可再发行包 MFC 安全更新

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

于 2011-12-28T07:59:30.797 回答
1

首先,我卸载了所有 Microsoft Visual C++ 2005 Redistributable Package 其次,我直接安装了 Microsoft Visual C++ 2005 SP1 Redistributable Package (x86)。它也不起作用,但是当我安装时

Visual C++ 2005 Service Pack 1 可再发行包 MFC 安全更新

它只是工作

于 2013-06-06T07:02:53.953 回答
1

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

于 2013-12-20T17:54:28.013 回答