problem with out-of-proc automation server

problem with out-of-proc automation server

Post by Kirill Cherbitsk » Tue, 04 Mar 2003 19:43:01



Hallo,

I have an MDI-Application with Automation support created
with VC++ 6 application wizard and statically linked MFC
libraries. So it has a COM Interface mapped to the
Document object.

I want to call some methods of this interface from C#-
written aspx. ASPCompat flag for the page is set to true.
I've given to ASPNET all possible rights to the COM server
in dcomcnfg.exe, and created a wrapper dll from the
typelib using tblimp.exe.

Now I start the application and then call the page via IE
on localhost. In Page_Load I call
Marshal.GetActiveObject("MYProcess.Document").
The call it brings the _COMPlusExceptionCode 0xe0434f4d.
Trying to make a new object brings the same.
"MYProcess.Document" ProgID is valid, I see it in the
registry.
Why the call fails ?

Alternatively, I tried to do following
Type type = typeof(DocumentClass);
Type dcomtype = Type.GetTypeFromCLSID( type.GUID,  false );
object dcomobj = Activator.CreateInstance( dcomtype );
doc = (DocumentClass)Marshal.CreateWrapperOfType( dcomobj,
type );
doc.SomeMethod();
In this way I get an exception
System.InvalidCastException: QueryInterface for interface
[x] failed
when I call the method.

Could somebody please comment ?

Thanks in advance.
Kirill Cherbitski