I have a serviced component installed in a COM+ server application. I want to create an instance from a remote client. The client needs to be able to specify the server machine's name dynamically. How do I do this?
I tried using Activator:
(XSLTransComponent.XSLTransformer)Activator.GetObject(
typeof(XSLTransComponent.XSLTransformer),
serverName
);
But I get this:
System.Runtime.Remoting.RemotingException: Cannot create channel sink to connect to URL 'server'. An appropriate channel has probably not been registered. at 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 do I specify a moniker for a remote object hosted on COM+ on server x?
Eureka! This works:
string serverName = serverTextBox.Text;
Type remote = Type.GetTypeFromProgID("XSLTransComponent.XSLTransformer", serverName);
return (XSLTransComponent.XSLTransformer)Activator.CreateInstance(remote);
Thanks to this question
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With