.NET Remoting :: Requested Service Not Found

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Airslash
    New Member
    • Nov 2007
    • 221

    .NET Remoting :: Requested Service Not Found

    Hello,

    I'm making a Windows Service that runs in the background and handles the .NET Remoting part on the server. This is the code currently available for my service when it starts.

    Code:
    protected override void OnStart(string[] args)
            {
                // Write in the EventLog of Windows that the remote service for BigBrother is starting.
                EventLog.WriteEntry("BigBrother Remote Service -- Starting up the Service.");
    
                // Create a new TCP channel for our service to listen on.
                TcpChannel channel = new TcpChannel(3000);
                EventLog.WriteEntry("BigBrother Remote Service -- Channel created on port 3000");
    
                // Register the channel so clients can remote access it.
                ChannelServices.RegisterChannel(channel, true);
                EventLog.WriteEntry("BigBrother Remore Service -- Channel registered.");
    
                // Register our RemoteManager class so clients can talk to it and perform
                // tasks.
                try
                {
                    WellKnownServiceTypeEntry srvcEntry = new WellKnownServiceTypeEntry(typeof(RemoteManager), "tcp://localhost:3000/BigBrotherRemoteService", WellKnownObjectMode.SingleCall);
                    RemotingConfiguration.RegisterWellKnownServiceType(srvcEntry);
                    EventLog.WriteEntry("BigBrother Remote Service -- Listener successfully registered.");
                }
                catch (Exception Ex)
                {
                    EventLog.WriteEntry("BigBrother Remote Service -- Failed to register the Listener :: " + Ex.ToString());
                }
            }
    This is the code of the object beeing made avaialble for remoting:
    Code:
    public class RemoteManager : MarshalByRefObject
        {
            public RemoteManager()
            { }
    
            public String Test()
            {
                return "Remote Manager greets you.";
            }
        }
    and this is the code that I'm using in the client application to connect to the service and try to execute the Test() method.

    Code:
    static void Main(string[] args)
            {
                // Create a channel for communicating with the remote object.
                TcpChannel channel = new TcpChannel();
                ChannelServices.RegisterChannel(channel, true);
    
                // Create an instance of the remote object.
                BigBrother_Remote_Library.RemoteManager manager = (BigBrother_Remote_Library.RemoteManager)Activator.GetObject(typeof(BigBrother_Remote_Library.RemoteManager), "tcp://localhost:3000/BigBrotherRemoteService");
    
                // Use the object.
                if (manager.Equals(null))
                {
                    System.Console.WriteLine("Failed to retrieve the remote object.");
                }
                else
                {
                    System.Console.WriteLine("Calling the Test function on our object.");
                    System.Console.WriteLine(manager.Test());
                }
    
                System.Console.ReadLine();
            }
    the code of the object in question is located inside a DLL file and has been referenced from the other projects. The code compiles but when I execute the client I recieve : The Requested Service cannot be found.

    What am I doing wrong/forgetting?
Working...