Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Calling remote DCOM server (Unmanaged Classic COM Component) from .NET client

177 views
Skip to first unread message

Michael Cruanes

unread,
Jan 8, 2002, 1:01:40 PM1/8/02
to
Hi,

I am developing a .NET client application that calls a classic COM server
located on a remote computer.

When I configure the location with the DCOMCNFG tool by checking the "Run
application on the following computer" check-box and giving the IP address,
it works fine. The new operator creates the remote object.
But I would like to do it programmatically within the .NET client
application.

How to tell the new operator the computer on which the COM object will be
instanciated ?

Thanks,
Michael

Joachim Fuchs

unread,
Jan 8, 2002, 1:23:57 PM1/8/02
to
Hi Michael,

I do this in VB, using CreateObject("My.Component", "192.168.0.2"). It still
works, even in a WebApplication.
You can either use the IP address or the computer name.

Joachim


NETMaster

unread,
Jan 8, 2002, 4:55:45 PM1/8/02
to
C# :
using System.Runtime.InteropServices;
// local: Type srvtype = Type.GetTypeFromProgID( "Company.Class", false );
Type srvtype = Type.GetTypeFromProgID( "Company.Class", "REMOTE-PC-NAME", false );
Object srvobject = Activator.CreateInstance( srvtype );

"Michael Cruanes" <michael...@nospam.omicron.at> wrote in message news:uy1RI6GmBHA.2432@tkmsftngp02...

Noah Kay-Oliphant

unread,
Jan 8, 2002, 5:30:55 PM1/8/02
to
I'm trying to use the code below to instantiate a COM component locally, but
get this error:

"Type must be a type provided by the runtime, not a TypeDelegator, etc.
Parameter name: type"

here is the code that breaks this (managed c++):

System::Type * srvtype =
System::Type::GetTypeFromProgID("SomeRegisteredCOM.Class", false);
Object * srvobject = Activator::CreateInstance(srvtype);

any ideas?
thanks

Noah

"NETMaster" <spam.ne...@swissonline.ch> wrote in message
news:ugo#68ImBHA.1928@tkmsftngp07...

NETMaster

unread,
Jan 8, 2002, 7:53:31 PM1/8/02
to
this :
Type * srvtype = Type::GetTypeFromProgID( S"Microsoft.XMLHTTP", false );

Object * srvobject = Activator::CreateInstance( srvtype );
works for me, empty wizard-created MC++ app (beta2) ...

you may check thread-apartment or your COM control registration.


"Noah Kay-Oliphant" <arkb...@aol.com> wrote in message news:eeagsOJmBHA.1856@tkmsftngp04...


> I'm trying to use the code below to instantiate a COM component locally, but
> get this error:
> "Type must be a type provided by the runtime, not a TypeDelegator, etc. Parameter name: type"

NETMaster

unread,
Jan 9, 2002, 5:36:04 AM1/9/02
to
IMPORTANT: check for null-return like:

System::Type * srvtype = System::Type::GetTypeFromProgID("SomeRegisteredCOM.Class", false);
if( srvtype == null )
failed!

then your string
"SomeRegisteredCOM.Class"
may be invalid.... (check COM registration)
or you may also try version-dependent like:
"SomeRegisteredCOM.Class.1"
(lookup in registry)

"Noah Kay-Oliphant" <arkb...@aol.com> wrote in message news:eeagsOJmBHA.1856@tkmsftngp04...

0 new messages