Friday, September 16, 2011

Calling MSScript.ocx on a 64 bit Machine

I struggled for a while today with a 3rd party .Net app our company uses to print documents.  We recently moved our production environment from 32 bit Windows Server to 64 bit.  It was seamless for the most part except for the previously mentioned app.

The error message we saw:

Retrieving the COM class factory for component with CLSID {0E59F1D5-1FBE-11D0-8FF2-00A0D10038BC} failed due to the following error: 80040154.


As far as useless error messages go, this is one ranks up pretty high on my list.  However it wasn't totally useless, turns out that CLSID was unique and a quick Google search led me to realize it was associated with the MSScriptControl.  Turns out this app was targeted for "Any CPU" and the script control is a 32 bit resource.  Since we weren't the developers of the code we couldn't just go in and re-build the app, luckily we were able to force the app to run in 32 bit using corflags.

After installing the Windows SDK for .Net you can find corflags.exe in C:\Program Files\Microsoft.NET\SDK\v2.0 64bit\Bin

Open up a command prompt in that directory and you can execute

CorFlags "C:\pathtoyour.exe" /32BIT+


And voila your app will now lunch as a 32 bit app and will load the 32 bit .dlls.