Friday, March 6, 2009

C++ Runtime Libraries Adventures

Almost no day passes without one of those "WHAT is happening?" moments. Yesterday there were 3 that happened to me. One required to delete temporary Internet Explorer files. Of course, I was stupid enough to require a colleague's advice on that. Another one, ironically, was caused by that same colleague adding a line of code in the wrong place. This one I fixed myself.

Now the third one was a bit more interesting and looks like a classic "worked on my machine!" situatuion.
Remember the application that uses the sophisticated scanner? Well, now it also uses a webcam. I was preparing the new version to ship. I build the installation package and installed the application on the test computer. When I try to use the webcam, I get our 'generic' error message, that can be caused by almost anything. But it worked on my machine, I swear!

Anyway, there is a way to find out what really happened - Event Log.

So, something is wrong with the webcam library QuickCamLib.dll. First thing that comes to mind - somehow not registered during installation process? Possible or not? Go go, regsvr32

Oh well, this is not my application problem. But what is wrong? The webcam drivers were installed and I can actually make webcam work (outside of the application).
Fortunately, I'm not the first one to have this problem.
This application has failed to start because the application configuration is incorrect

The thread suggests to look in the System part of the Event Log for a 'side by side' error - and there it is!

The thread also contains the solution, which is somewhat complicated but precise, except in my case I have '90' instead of '80'.

"You need to copy CRT DLL into your application local folder together with the manifest. Please take a look on this post on my blog, Basically go to windows\winsxs folder. Find a folder like x86_Microsoft.VC80.CRT and copy DLL from there to your application local folder. From what I see in your code you need msvcrt80.dll and msvcp80.dll (perhaps msvcrt80d.dll and msvcp80d.dll if this is Debug mode application). Then go to windows\winsxs\manifests folder and copy x86_*_Microsoft.VC80.CRT*.manifest to Microsoft.VC80.CRT.manifest to your application local folder."

I copy the 4 files msvcm90.dll, msvcp90.dll, msvcr90.dll and Microsoft.VC90.CRT.manifest into my application folder on the test computer, and it works like a charm. I add these files to the installation package, reinstall the application and it works again. All is well that ends well I guess.

by . Also posted on my website

No comments: