[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

Remoting and security limit problem,help

whtinkm

7/21/2004 3:49:00 AM

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

Harry
2 Answers

Sunny

7/21/2004 2:25:00 PM

0

Hi,

you need to set typeFilterLevel = "Full".

This is a property of the formatter. So you need to create a server and
client formatters both at the server and client, with the appropriate
constructor, which accepts IDictionary as a parameter.

Then create the channel with the constructor, which accepts IDictionary,
serverformater and clientformatter.

Sunny

In article <4432e092.0407201949.56764c44@posting.google.com>,
whtinkm@sina.com says...
> 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
>
> Harry
>

whtinkm

7/22/2004 8:31:00 AM

0

Thanks