简体   繁体   中英

C# COM server access from JScript

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?

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

如果问题是x64,请参阅Hot的答案以使COM ActiveX对象在IE 64位上工作?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM