Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Remoting / March 2007

Tip: Looking for answers? Try searching our database.

Help Needed..dotnet remoting security issue

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sumu - 08 Mar 2007 09:45 GMT
Hello,

  I am trying to develop a dot net client server application.My
application works perfects on LAN..The problem arised when i tried to
host the remote object in a webserver.
The error i get is
" Type System.DelegateSerializationHolder and the types derived from
it (such as System.DelegateSerializationHolder) are not permitted to
be deserialized at this security level."
I am aware of the security issue in dotnet and am using
typefilterlevel.Full in both server and client.
I will paste my code for your reference

//code in server

public string StartHttpServer()
{
HttpChannel chnl;
retmsg="ok";
try
{
BinaryServerFormatterSinkProvider ServProv=new
BinaryServerFormatterSinkProvider();
ServProv.TypeFilterLevel=System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
BinaryClientFormatterSinkProvider ClientProv=new
BinaryClientFormatterSinkProvider();
IDictionary props=new Hashtable();
props["port"]=4444;
props["typeFilterLevel"] = "Full";
chnl=new HttpChannel(props,ClientProv,ServProv);
ChannelServices.RegisterChannel(chnl);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(Remoting.Remotableobject),"Remotableobject.rem",WellKnownObjectMode.Singleton);
props.Clear();
props=null;
}
catch(Exception ex)
{
retmsg=ex.Message;
}
return retmsg;
}

//Code in Client

public ChatCenter(callbackclass callbackobj,Remotableobject
remfromLogin)
{
callback=callbackobj;
rem=remfromLogin;

IDictionary props=new Hashtable();
BinaryServerFormatterSinkProvider serv=new
BinaryServerFormatterSinkProvider();
BinaryClientFormatterSinkProvider cl=new
BinaryClientFormatterSinkProvider();
serv.TypeFilterLevel=System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

props["typeFilterLevel"] = TypeFilterLevel.Full;
props["port"]=0;

chnl=new HttpChannel(props,cl,serv);
ChannelServices.RegisterChannel(chnl);
props.Clear();
props=null;
try
{
rem= (Remoting.Remotableobject)
Activator.GetObject(typeof(Remoting.Remotableobject),server);

//Here the remote object returns the server ip without any problem.
MessageBox.Show(rem.checkConnectivity());

//The error is thrown from this statement
rem.eventRxText+=new ReceieveText(callback.rem_eventRxText);
rem.eventGtUsers+=new getusers(callback.rem_eventGtUsers);

}
catch(Exception ex)
{
MessageBox.Show(null,ex.Message,"Unable to reach
server",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
System.IO.StreamWriter sr=new System.IO.StreamWriter(@"E:\dotnet\c#
\RemoteClient\log.htm",true);
sr.Write(ex.Message);
sr.Close();
}
}

Please somebody help me..
I am struggleing with this for one week.

Thanks in Advance
Vertygo - 09 Mar 2007 15:47 GMT
Here is my example that works:

Server:

           BinaryClientFormatterSinkProvider clientProvider = new
           BinaryClientFormatterSinkProvider();
           BinaryServerFormatterSinkProvider serverProvider = new
           BinaryServerFormatterSinkProvider();
           serverProvider.TypeFilterLevel =
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

           ht["name"] = string.Empty;
           ht["port"] = 9000;
           ht.Add("typeFilterLevel",
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full);

           TcpChannel channel = new TcpChannel(ht, clientProvider,
serverProvider);
           ChannelServices.RegisterChannel(channel);

           string identifier = "Downloader";
           WellKnownObjectMode mode = WellKnownObjectMode.Singleton;

           WellKnownServiceTypeEntry entry = new
WellKnownServiceTypeEntry(typeof(ServerTalk),
               identifier, mode);
           RemotingConfiguration.RegisterWellKnownServiceType(entry);

Client:

           BinaryClientFormatterSinkProvider clientProvider = new
           BinaryClientFormatterSinkProvider();
           BinaryServerFormatterSinkProvider serverProvider = new
           BinaryServerFormatterSinkProvider();
           serverProvider.TypeFilterLevel =
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
           TcpChannel channel;
           RemotingConfiguration.CustomErrorsEnabled(false);
           System.Collections.IDictionary oChannelProperties = new
System.Collections.Hashtable();
           oChannelProperties.Add("name", string.Empty);
           oChannelProperties.Add("port", 0);
           oChannelProperties.Add("typeFilterLevel",
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full);

           channel = new TcpChannel(oChannelProperties,
clientProvider, serverProvider);

           RemotingConfiguration.CustomErrorsEnabled(false);
           if(RemotingConfiguration.CustomErrorsMode !=
CustomErrorsModes.Off)
           RemotingConfiguration.CustomErrorsMode =
CustomErrorsModes.Off;

   
System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel,
false);

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.