【问题标题】:Program initialization failed (0xc0150002) when start a program depend on a third party dll启动依赖第三方dll的程序时程序初始化失败(0xc0150002)
【发布时间】:2011-12-27 12:50:36
【问题描述】:

当我写一个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(由供应商分发)中的版本号不匹配。然后我用 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 它认为它应该是一个版本号(不是上面显示的两个)。我在 C:\Windows\WinSxS 中找到了 Microsoft.VC80.CRT dll 和 Microsoft.VC80.MFC dll 以及相应的清单文件(所有版本号都是 8.0.50727.6195 并将其放在与 @ 相同的目录中987654336@(我的程序)。它也不能工作。 为了弄清楚问题。我使用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。

【问题讨论】:

  • 该清单被搞砸了,看起来该 DLL 与使用 VS2005 测试版构建的代码链接。您需要获得更好的构建,联系供应商或作者寻求支持。
  • @HansPassant 但它在我同事的电脑上运行良好。我只是想让它工作。可能很难联系到供应商。
  • 启动程序时好像只有我的电脑出现故障。
  • @HansPassant 无论如何感谢您的帮助。
  • 很难相信没有人仅仅因为相对努力就投票赞成这个:+1

标签: visual-c++ dll visual-studio-2005 side-by-side winsxs


【解决方案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 Redistributable Package MFC Security Update

它只是工作。看来要更新旧版本的Microsoft Visual C++ 2005 Redistributable Package,然后让新版本(sp1)工作。

【讨论】:

    【解决方案2】:

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

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

    它只是工作

    【讨论】:

      【解决方案3】:

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

      【讨论】:

      • 这,好先生,非常宝贵!感谢您发布此内容。
      猜你喜欢
      • 2012-09-10
      • 2012-09-04
      • 2011-04-02
      • 1970-01-01
      • 2014-05-30
      • 1970-01-01
      • 2021-07-23
      • 2019-08-07
      相关资源
      最近更新 更多