I have a COM+ dll installed in a COM application on 2 remote servers. I have exported a non-queued proxy from one of the servers and installed it on a client machine.
I want to be able to specify which remote server the COM object is instantiated on at runtime - the proxy installation contains the Remote Server Name of the machine I exported the proxy from, so simply creating the proxy on the client will always call the machine I exported it from, since it's part of the proxy properties.
The proxy is not queued, so I can't use the method of calling GetObject with a PathName like queue:ComputerName=Server01/new:ComClass.Class.
For non-queued proxies that will always call the remote server they were exported from I just use CreateObject(objectName) and it will use the Remote Server Name from the proxy properties.
After some searching I found a solution (in my self-answer below) but is there a simpler way of doing it within VB6 without having to use the ole32.dll functions?
Edit: After testing the solution proposed by @Bob77 in the comments, called CreateObject with the server name parameter has no effect. Only using the CreateRemoteObject method outlined actually calls the COM component on the specified server.
This may be because the client call is from an IIS process and the user identity of the remote server's COM+ application is different.
CreateObjectcall? That's what it is there for. - Bob77CreateObjectdoes not result in the COM class getting called on the remote server. No idea why though, but I suspect this is why the current solution is present. - Matt Hogan-Jones