toolchainX
toolchainX

Reputation: 2057

Program initialization failed (0xc0150002) when start a program depend on a third party dll

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.

Upvotes: 1

Views: 8877

Answers (3)

Kevin Smyth
Kevin Smyth

Reputation: 1937

0xC0150002L is STATUS_SXS_CANT_GEN_ACTCTX. The tool for debugging activation context issues is SxsTrace. Try this:

touch program.exe
SxsTrace Trace -logfile:SxsTrace.etl
[run program.exe]
SxsTrace Parse -logfile:SxsTrace.etl -outfile:SxsTrace.txt

SxsTrace.txt will contain the name of the assembly that is referenced and can't be found.

Upvotes: 1

kilian
kilian

Reputation: 11

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

Upvotes: 1

toolchainX
toolchainX

Reputation: 2057

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 installed

Visual 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.

Upvotes: 1

Related Questions