Calling a remote COM+ ServicedComponent from a C# client
Asked Answered
Y

1

6

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?

Yearround answered 27/1, 2009 at 20:6 Comment(0)
Y
3

Eureka! This works:

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

Thanks to this question

Yearround answered 27/1, 2009 at 20:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.