dotnet remoting:
I'm having some trouble updating data inside my remote object.
Basically I have a remote object server running as a windows service,
serving up a marshalbyref object called 'ConfigController'.
'ConfigController' contains another object, which is marshal by value.
When I try to remotely update data inside that marshal by value object
it doesn't change the data, and no error occurs. I've even tried making
an UpdateValue() function in the 'ConfigController' ref object to see
if it would update the data, and it seems to update the data on the
server (as verified with remote debugger) the client doesn't see the
changes to the data.
Some example code:
[Server] (running as a service)
=====================================
IDictionary props = new Hashtable();
props["port"] = port;
BinaryServerFormatterSinkProvider provider = new
BinaryServerFormatterSinkProvider();
provider.TypeFilterLevel = TypeFilterLevel.Full;
TcpChannel chan = new TcpChannel(props, null, provider);
ChannelServices.RegisterChannel(chan, false);
//register remote object
RemotingConfiguration.CustomErrorsEnabled(false);
RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off;
RemotingConfiguration.RegisterWellKnownServiceType(typeof(ConfigController),
"ConfigServer", WellKnownObjectMode.Singleton);
// Initialize the object when the service starts,
// so it's constructor is called upon service start, instead of first
client usage.
configController =
(ConfigController)Activator.GetObject(typeof(ConfigController),
String.Format("tcp://localhost:{0}/ConfigServer", port));
configController.Init();
[Client]
=====================================
BinaryClientFormatterSinkProvider clientProvider = new
BinaryClientFormatterSinkProvider();
BinaryServerFormatterSinkProvider serverProvider = new
BinaryServerFormatterSinkProvider();
serverProvider.TypeFilterLevel =
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
IDictionary props = new Hashtable();
props["port"] = 0;
string s = System.Guid.NewGuid().ToString();
props["name"] = s;
props["typeFilterLevel"] =
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
TcpChannel chan = new TcpChannel(props,clientProvider,serverProvider);
ChannelServices.RegisterChannel(chan,false);
// Grab a reference to the remote object
configController =
(ConfigController)Activator.GetObject(typeof(ConfigController),
String.Format("tcp://{1}:{0}/ConfigServer", configport, configserver));
// marshalbyref.marshalbyval.value = (string)
configController.ConfigSettings.TestValue = "this is a test";
Console.WriteLine(configController.ConfigSettings.TestValue);
// output: "" (initialized value)
[Remoted Object]
[Serializable]
public class ConfigController : MarshalByRef, ISerializable
{
// ConfigObj is just a regular object, and contains a string prop
called TestValue
public ConfigObj ConfigSettings = new ConfigObj();
public ConfigController()
{
}
public void Init()
{
ConfigSettings.TestValue="";
}
}
Is this normal remoting behaviour? Am I missing something about .Net
remoting that I thought used to work? Please note (and thanks for
getting this far) this is fake code I typed up and not the real code..
principles are the same. I'm using TCP remoting on two seperate
machines.
Thanks!
Michael Brown