.net remoting problem while hosting in public IIS
Hello,
I am struggling with .net remoting for two weeks.i need some one's help very badly please.Ill describe my problem.
I am in developing a chat server in remoting.I devloped it with basic funtionalities.i hosted server as windows service and in IIS.both worked perfectly in my LAN.Now with that confidence i tried to host my server in a public server. Now my app is not working as am expected.
I will paste the code here am using in Application_start method in global.cs in hosted web application.
HttpChannel chnl;
SoapServerFormatterSinkProvider ServProv=new SoapServerFormatterSinkProvider();
ServProv.TypeFilterLevel=System.Runtime.Serializat ion.Formatters.TypeFilterLevel.Full;
SoapClientFormatterSinkProvider ClientProv=new SoapClientFormatterSinkProvider();
IDictionary props=new Hashtable();
props["port"]=1234;
props["name"]="abc";
props["typeFilterLevel"] = System.Runtime.Serialization.Formatters.TypeFilter Level.Full;
chnl=new HttpChannel(props,ClientProv,ServProv);
ChannelServices.RegisterChannel(chnl);
RemotingConfiguration.RegisterWellKnownServiceType (typeof(Remoting.Remotableobject),"Remotableobject .soap",WellKnownObjectMode.Singleton);
//Code in my windows app to connect to server
string server=@"http://www.sumesh.somee.com:1234/Remotableobject.soap";
IDictionary props=new Hashtable();
SoapServerFormatterSinkProvider serv=new SoapServerFormatterSinkProvider();
SoapClientFormatterSinkProvider cl=new SoapClientFormatterSinkProvider();
serv.TypeFilterLevel=System.Runtime.Serialization. Formatters.TypeFilterLevel.Full;
props["typeFilterLevel"] = TypeFilterLevel.Full;
props["name"]="abc";
props["port"]=0;
chnl=new HttpChannel(props,cl,serv);
ChannelServices.RegisterChannel(chnl);
rem= (Remoting.Remotableobject) Activator.GetObject(typeof(Remoting.Remotableobjec t),server);
MessageBox.Show(rem.checkConnectivity());//returns ip address of server
rem.eventRxText+=new ReceieveText(callback.rem_eventRxText);
rem.eventGtUsers+=new getusers(callback.rem_eventGtUsers);
rem.TestEvent+=new Testdel(callback.rem_TestEvent);
If i run my client app ill get a connection time out exceptionwhen at this code statement
MessageBox.Show(rem.checkConnectivity());
Now if i replace
string server=@"http://www.sumesh.somee.com:1234/Remotableobject.soap";
with
string server=@"http://www.sumesh.somee.com/Remotableobject.soap";
I will get the ip address from
MessageBox.Show(rem.checkConnectivity());
but at next statement, that is
rem.eventRxText+=new ReceieveText(callback.rem_eventRxText); i get exception
Type System.DelegateSerializationHolder and the types derived from it (such as System.DelegateSerializationHolder) are not permitted to be deserialized at this security level.
now again if comment the line props["port"]=1234; on server and run the client with the url
string server=@"http://www.sumesh.somee.com/Remotableobject.soap";
ill get NO error on these four statements
MessageBox.Show(rem.checkConnectivity());
rem.eventRxText+=new ReceieveText(callback.rem_eventRxText);
rem.eventGtUsers+=new getusers(callback.rem_eventGtUsers);
rem.TestEvent+=new Testdel(callback.rem_TestEvent);
but when i call a method in remote object, say
rem.login(username,pass) which contains firing of an event, that is like this
//this is in remoteobject
public bool login(string uname,string pwd)
{
currentusers.Add(uname);
TestEvent();
return true;
}
An exception is thrown here on statement
TestEvent();
that is:object reference not set to an instance of an object
The thing is that the same remoteobject without any change in code will work perfectly if i host my server in my local IIS with setting port number on server and using this url on client
"http://localhost:1234/Remotableobject.soap"
but sometimes here also i get the error
object reference not set to an instance of an object while firnig event in remote object.
can anybody help me on this please??
|