Call Remote COM + ServicedComponent from C # Client

I have a serviced component installed in a COM + server application. I want to create an instance from a remote client. The client should be able to specify the name of the machine server dynamically. How to do it?

I tried using Activator:

(XSLTransComponent.XSLTransformer)Activator.GetObject( typeof(XSLTransComponent.XSLTransformer), serverName ); 

But I get this:

System.Runtime.Remoting.RemotingException: Cannot create a channel to connect to the server URL. Probably the corresponding channel has not been registered. in System.Runtime.Remoting.RemotingServices.Unmarshal (type classToProxy, string URL, object data)

Do I need to register a channel? If so, how?

Another idea is to use Marshall.BindToMoniker, but how to specify a nickname for a remote object hosted on COM + on server x?

+6
com +
Jan 27 '09 at 20:06
source share
1 answer

Eureka! It works:

 string serverName = serverTextBox.Text; Type remote = Type.GetTypeFromProgID("XSLTransComponent.XSLTransformer", serverName); return (XSLTransComponent.XSLTransformer)Activator.CreateInstance(remote); 

Thanks to this question

+3
Jan 27 '09 at 20:57
source share



All Articles