2010/07/18

The Saga of COMException (0x800736b1)

So I had a very lovely weekend being sexually assaulted by a pesky problem while installing an ASP.NET application on a Windows XP IIS server.


Server Error in '/AppName' Application.


This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. (Exception from HRESULT: 0x800736B1)



Exception Details:System.Runtime.InteropServices.COMException: This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. (Exception from HRESULT: 0x800736B1)


Ok, this is lovely. Tracing the error code was pretty straight forward and pointed to the lack of VC++ Redistributable DLLs on the target machine. They are present on the developer box, but are missing on target. Sounds easy enough, downloaded vc_redistx86.exe , installed - same result.

Excellent. So, using depends.exe, I checked that the DLL in question is looking for msvcr80.dll and friends. Curiously enough - they were installed on the system, but the problem persisted, the application just didn't pick them up.

So I dug some more, and came across a folder \Windows\WinSxS (http://msdn.microsoft.com/en-us/library/aa376307(VS.85).aspx). It's Microsoft's solution to DLL Hell. There are several versions of the same CRT DLLs, in subfolders with different version names.

Which pointed me to the fact that it's not that the DLL is missing, but it's of incorrect version. So what was left is to discover how exactly does the application select which DLL to load. (it's obviously not by name!). So after frantic Google searches I came across a beast whom I met before but didn't pay attention to - "XP Manifest". 

It's a XML file which is embedded inside the application/DLL as a resource, and can define properties like 'Dll dependency'. So a quick run of ResHacker, patching the XP Manifest, saving the new app, re running, seeing that it works and then promising my self to tear away the nads of whomever though it would be a great idea to make me spend my weekend tracking this shit, and not just showing me a freaking help message!

2 comments:

  1. Ahh. This helped me today. I had compiled a Debug assembly instead of Release, so it referenced the MSVCR90D.dll (Debug dll which doesn't exist on deployment server) instead of just MSVCR90.dll.

    Thank you! :-)

    ReplyDelete
  2. Glad to hear that helped, it's was a doosy of a goose chase.

    ReplyDelete