Some notes on software development... RSS 2.0
# Thursday, 31 May 2012

If you are unfortunate enough to be working with VB6, VBScript, Classic ASP and COM components on a 64-bit machine you need to make sure your calling code is running the same process type as the COM component.

When you register a 32-bit COM component on a 64-bit machine it adds all the relevant bits to the HKEY_CLASSES_ROOT\Wow6432Node\CLSID node in the registry.
Here I have registered a 32-bit COM component and searched for it’s class id:

image

If the consuming client is running in a 64-bit process, when it tries to create the object it will fail because it will look in the default 64-bit area of the registry.

For my tests I have a COM component registered called HTestLibrary.

VBScript 
I have the following VBScript to create the object:

    Dim y
    Set y = CreateObject("HTestLibrary3.MyClass3")

    MsgBox y.GetTestString3()

Running the VBScript directly on 64-bit machine caused the following error:

image

By default the the script runner (cscript or wscript) is run under a 64-bit process so the COM registry lookup fails. To run the script under 32-bit process you need run the 32-bit version of cscript or wscript, this can be done by using the 32-bit version of CMD:

%WINDIR%\SysWoW64\cmd.exe

image

Classic ASP
The error you get when using Classic ASP in 64-bit mode is ‘Automation server can't create object’. To fix this you need to set the application pool for the website to run under 32-bit process so in the advanced settings for the application pool set the ‘Enable 32-Bit applications’ setting to true:

image

Links:
MSDN - COM Component Compatibility
SO - How do I run a VBScript in 32-bit mode on a 64-bit machine?

Thursday, 31 May 2012 09:25:09 (GMT Standard Time, UTC+00:00)  #    -
Classic ASP | COM | VB6
Navigation

Sign In
Extras
Statistics
Total Posts: 116
This Year: 0
This Month: 0
This Week: 0
Comments: 36
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2017
Hadrian Phillips

All Content © 2017, Hadrian Phillips
DasBlog theme 'Business' created by Christoph De Baene (delarou)