G
Gelios
Hi All!
Probably my question is newbie but anycase.
Should I do object that I want to pass as parameter to remoting object serializable?
For Example:
//server
public class MyServerObject
{
Settings settings = Settings.Instance();
public static void Main()
{
settings.Restore();
//Initialize TCP channel and Remoting object
//channel properties
IDictionary props = new Hashtable();
props["name"] = "Channel1";
props["port"] = settings.getServerPort();
//create channel
TcpChannel channel = new TcpChannel(props, null, new BinaryServerFormatterSinkProvider());
ChannelServices.RegisterChannel(channel);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyRemotingObject ),
"ServerUri", WellKnownObjectMode.Singleton);
}
}
//client
public class MyClientObject
{
Settings settings = Settings.Instance();
public static void Main()
{
this.settings.Restore();
string serverUri = "tcp://" + settings.getServerAddress() + ":" + settings.getServerPort() + "/ServerUri";
TcpChannel chan = new TcpChannel();
ChannelServices.RegisterChannel(chan);
serverObject = (MyRemotingObject) Activator.GetObject(typeof(MyRemotingObject), serverUri);
if (serverObject == null) LoggingProcessor.Error("Could not locate server");
//do something
ServiceObject serviceObject = new ServiceObject();
serviceObject.str1 = "this is a string";
serviceObject.num1 = 12;
serverObject.myMethod(serviceObject);
}
}
//remitong object
public class MyRemotingObject : MarshalByRefObject
{
public void myMethod(MySomeObject myObject)
{
// do somethinng
}
}
//service object
public class ServiceObject
{
public string str1;
public int num1;
public int num2
}
In given case I got following error:
An unhandled exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll
Additional information: The type SES.Tools.General.Queue in Assembly Tools, Version=1.0.1934.2848, Culture=neutral, PublicKeyToken=null is not marked
as serializable.
I tried declare ServiceObject as [Serializable] and got following error:
An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
Additional information: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
Any ideas?
Probably my question is newbie but anycase.
Should I do object that I want to pass as parameter to remoting object serializable?
For Example:
//server
public class MyServerObject
{
Settings settings = Settings.Instance();
public static void Main()
{
settings.Restore();
//Initialize TCP channel and Remoting object
//channel properties
IDictionary props = new Hashtable();
props["name"] = "Channel1";
props["port"] = settings.getServerPort();
//create channel
TcpChannel channel = new TcpChannel(props, null, new BinaryServerFormatterSinkProvider());
ChannelServices.RegisterChannel(channel);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyRemotingObject ),
"ServerUri", WellKnownObjectMode.Singleton);
}
}
//client
public class MyClientObject
{
Settings settings = Settings.Instance();
public static void Main()
{
this.settings.Restore();
string serverUri = "tcp://" + settings.getServerAddress() + ":" + settings.getServerPort() + "/ServerUri";
TcpChannel chan = new TcpChannel();
ChannelServices.RegisterChannel(chan);
serverObject = (MyRemotingObject) Activator.GetObject(typeof(MyRemotingObject), serverUri);
if (serverObject == null) LoggingProcessor.Error("Could not locate server");
//do something
ServiceObject serviceObject = new ServiceObject();
serviceObject.str1 = "this is a string";
serviceObject.num1 = 12;
serverObject.myMethod(serviceObject);
}
}
//remitong object
public class MyRemotingObject : MarshalByRefObject
{
public void myMethod(MySomeObject myObject)
{
// do somethinng
}
}
//service object
public class ServiceObject
{
public string str1;
public int num1;
public int num2
}
In given case I got following error:
An unhandled exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll
Additional information: The type SES.Tools.General.Queue in Assembly Tools, Version=1.0.1934.2848, Culture=neutral, PublicKeyToken=null is not marked
as serializable.
I tried declare ServiceObject as [Serializable] and got following error:
An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
Additional information: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
Any ideas?