.NET Framework Bookmark and Share   
 index > .NET Remoting and Runtime Serialization > Remoting Trouble. I am at a standstill
 

Remoting Trouble. I am at a standstill

I am trying to do a simple remoting application and I have read a ton of internet tutorials but I still can't get remoting to work. I have an interface that is compiled to a .dll and referenced by both the server and client application. ther server application has an object that derives fromboth the interface AND MarshalByRefObject. I repeat, it derives from MarshalByRefObject. The client application then attempts to use methods on the server that are exposed by the interface. But... it does not work and I do not know why. I don't even have any guesses so if you can help that would really be appreciated. Below is the code. Please keep in mind there might be small errors from this or that. Do not point those out. Please just explain what the remoting problem is.Thank You.

INTERFACE

using

System;

using

System.Collections.Generic;

using

System.Linq;

using

System.Text;

namespace

i

{

public interface i

{

string FunctionOne(string str);

}

}






SERVER

using

System;

using

System.Runtime.Remoting;

using

System.Runtime.Remoting.Channels;

using

System.Runtime.Remoting.Channels.Tcp;

public

class s

{

public static void Main()

{

TcpChannel m_TcpChan = new TcpChannel(8888);

ChannelServices.RegisterChannel(m_TcpChan, false);

RemotingConfiguration.RegisterWellKnownServiceType(typeof(i.i), "FirstRemote", WellKnownObjectMode.Singleton);

System.

Console.WriteLine("Press ENTER to quit");

System.

Console.ReadLine();

}

public class MyRemoteClass : MarshalByRefObject, i.i

{

public string FunctionOne(string str)

{

return "Server: " + str;

}

}

}


CLIENT

using

System;

using

System.Linq;

using

System.Net;

using

System.Runtime.Remoting;

using

System.Runtime.Remoting.Channels;

using

System.Runtime.Remoting.Channels.Tcp;

class

c

{

public static void Main()

{

string serverAddress = Dns.GetHostEntry("www.kristieisacutiepie.info").AddressList.ElementAt(0).ToString();

TcpChannel m_TcpChan = new TcpChannel();

ChannelServices.RegisterChannel(m_TcpChan, false);

i.

i m = (i.i)Activator.GetObject(typeof(i.i), "tcp://127.0.0.1:8888/FirstRemote");

//i.i m = (i.i)Activator.GetObject(typeof(i.i), "tcp://" + serverAddress + ":9999/FirstRemote");

//i.i m = (i.i)Activator.GetObject(typeof(i.i), "tcp://192.168.200.252:9999/FirstRemote");

m.ToString();

// Console.WriteLine(m.FunctionOne("This is the Client!"));

// Console.ReadLine();

}

}

WreckingBall2

At server side, replace

RemotingConfiguration.RegisterWellKnownServiceType(typeof(i.i), "FirstRemote", WellKnownObjectMode.Singleton);

with

RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyRemoteClass), "FirstRemote", WellKnownObjectMode.Singleton);

and it should work.

To check it, add the following lines to the client:

Console.WriteLine(m.FunctionOne("blabla"));
Console.ReadLine();

Kind regards,
Stefan

Stefan H.F. A.

You can use google to search for other answers

Custom Search

More Threads

• CallContext Problems
• Remoting
• authentication for creating a remote sever object
• Specifying a server for COM+ class instancing
• Handling disconnections
• ObjectManager Memory Growth
• Assign a client's handler to a server's event
• Alter IMessage in Custom Sink
• System.Runtime.Serialization.InvalidDataContractException using a ObservableCollection in a Service
• Remoting