1

Using .NET remoting I have a server application which must communicate with a separate server monitor application. The server monitor should be able to see all kinds of information about the server, such as a list of clients.

I've set up a .NET remote object which the server monitor will interface to. The .NET remote object has all of the methods it needs to be able to send appropriate data because I gave it references to modules of the server through it's constructor.

I then painfully found out that I cannot give the constructor arguments since it is a .NET remote object. Then I came to the realisation that I cannot even access the object in any obvious way since I do not have a reference to the instantiation.

How do I make my remote object useful in such a way that it can access data within the server?

Many thanks!

Stephen Foster
  • 763
  • 2
  • 7
  • 20
  • just a side comment: .net remoting is quite an [old technology](http://stackoverflow.com/q/1294494/706456) – oleksii Apr 11 '14 at 10:45
  • 1
    The page http://msdn.microsoft.com/en-us/library/vstudio/5dwytyss.aspx is full of examples on how to do this. But I'd like to quote: "This topic is specific to a legacy technology that is retained for backward compatibility with existing applications and is not recommended for new development." – Kris Vandermotten Apr 11 '14 at 10:45
  • I didn't know it was old to be honest! What alternative would you recommend for my purposes? I was going to use a WCF web service but I have the same issue of lack of accessibility from the host application to the service. – Stephen Foster Apr 11 '14 at 10:54

1 Answers1

1

If I understand correctly, you need access to the instance of the object that is remoted? I assume you are registering your remote object as a singleton and have something similar to the following:

RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyRemoteObject), "MyRemoteObject.rem", WellKnownObjectMode.Singleton);

Instead you can register the object like this:

MyRemoteObject myRemoteObject = new MyRemoteObject(); RemotingServices.Marshal(myRemoteObject, "MyRemoteObject.rem");

This allows you access to the instance that is remoted.

nblackburn
  • 338
  • 2
  • 10