Question

i'm writing an application that uses .net Remoting via MarshalByRefObject. I can connect and everything works fine for simple things like method calls. now the problem is, when i try to access properties on an object i received from an earlier call, the property-getters are execute "client"-side, and not inside the host process.

inside these getters i'm using Marshalling on the local process, so they are required to be running on the host process instead of the client.

My question now: is there any specific way to achieve what i'm trying to do, or will i have to go the route and on the host-side write additional methods in the exposed interface and implementing class, that will return the value of the getters?

My code looks like this:

MyApi api = new MyApi();
var channel = new IpcChannel(processId.ToString());
ChannelServices.RegisterChannel(channel, false);
RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.On;
RemotingConfiguration.ApplicationName = "MyApi-Server" + processId;
RemotingServices.Marshal(api, "service");

for the host process.

And this is the Client-Side

api = (IMyApi)Activator.GetObject(typeof(IMyApi), "ipc://MyApi-" + process.Id + "/service");
MessageBox.Show(api.GetSomething().Someproperty);

thanks for your help

Was it helpful?

Solution

outch, i'm stupid. not only the implementation of the interface class should derive from MarshalByRefObject, all the other objects that i'm passing around should too.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top