How do I access .Net objects in another process?
I have a .Net app running.
I want another .Net app to connect the the first app and call public methods on one of its objects.
I know I can do this via WCF, but my understanding is that .Net objects are all components in the COM sense, and so I assume can be marshalled across process boundaries on the same machine.
Is this possible? And if开发者_Go百科 so how do I get hold of the object in the first app from the second?
Many thanks for any help.
Any object that inherits from MarshalByRefObject can be accessed across process boundaries (this is different from being COM visible though). This is what wcf will use under the bonnet.
However, if you use wcf instead of (lower-level) Remoting then you allow the long-term option of crossing machine boundaries (remoting does allow you to do this too, but it's even more convoluted than wcf... edit - and less secure too, as noted in the link provided by daniel in the comments below).
In short, I agree with Daniel - you're better off sticking with WCF - for future options and ease of use.
Your understanding is not correct. By default, .NET classes are no COM objects. You can, however, make them COM visible, either on a per class basis or for the whole assembly.
Having said that, this is not going to help you, because the COM objects are running in-proc with the process that uses them, i.e. it runs in your second application. You can't connect to another application like this.
You really should use WCF to accomplish this task.
精彩评论