views:

54

answers:

2

I have a COM server, implemented in C#. It exposes a class decorated like this:

[ComVisible(true)]
[ProgId("MyServer.MyClass")]
[ClassInterface(ClassInterfaceType.AutoDispatch)]

I registered the DLL with "regasm /codebase MyServer". This server must be used from a WSC (a COM server implemented in JScript). Therefore I used the AutoDispatch interface.

When the WSC calls o = new ActiveXObject("MyServer.MyClass"); I get the error "Automation serve can't create object".

I checked the registration of the COM server with this C++ program:

hr = ::CoInitialize(NULL);
hr = ::CLSIDFromProgID(L"MyServer.MyClass", &clsid);
hr = ::CoCreateInstance(clsid, NULL, CLSCTX_ALL, IID_IDispatch, (void**)&pObj);

and was able to create the object. All return values have been checked to be S_OK.

What is needed to make the COM server accessible for JScript?

A: 

Are the types used in your class ole automation compatible? I don't know if jscript checks for oleautomation compatibility up front.

bacar
A: 

If the problem is x64, see the answer of Hot to make COM ActiveX object work in IE 64 bit?

VirtualBlackFox