Hi all
I begin to study .Net remoting recently,and I happend to a problem.
The following is my test code
//share dll
namespace sharedll
{
public class FirstClass:System.MarshalByRefObject
{
public FirstClass()
{
}
public void SetData(SecondClass oneClass)
{
System.Console.WriteLine(oneClass.GetData());
}
}
public class SecondClass:System.MarshalByRefObject
{
public SecondClass()
{
}
public string GetData()
{
return "come from second class";
}
}
}
//server
TcpServerChannel channel=new TcpServerChannel(7777);
ChannelServices.RegisterChannel(channel);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(FirstClass),"
FirstClass ",WellKnownObjectMode.Singleton);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(SecondClass),"
SecondClass ",WellKnownObjectMode.Singleton);
//client
ChannelServices.RegisterChannel(new TcpClientChannel());
FirstClass first=(FirstClass)Activator.GetObject(typeof(FirstClass),"tcp://localhost:7777/
FirstClass ");
SecondClass second=(SecondClass)Activator.GetObject(typeof(SecondClass),"tcp://localhost:7777/
SecondClass");
first.SetData(second); //This call will cast a exception.
It says "Because of security limit,cann't visit type
System.Runtime.Remoting.ObjRef."
Please help
Thanks