.NET 1.x remoting hell!
-
Hello, I've got a very big problem with the .NET remoting. I've developed a synchronization library using .NET 2.0 that uses classes derived from
MarshalByRefObject
. These classes have public events which remote objects can subscribe to. Under the 2.0 framework, everything works like a charm. Now I have to port the library to .NET 1.x since my teachers want to be able to test and compile the code by themselves. I though that this would be a task of a few minutes. I guessed wrong. The runtime refuses to serialize the delegates. I've read something aboutRemotingSurrogateSelector
, but I can't find a thorough explanation about how the class should be used to handle this type of serialization. Does anybody know how I can subscribe to a remote event? Source example:// The delegate
public delegate void MyDelegate();
// The remote (server) object
class RemoteObject : System.MarshalByRefObject
{
// code...public event MyDelegate EvMyEvent;
}
// The client object
class MyClient
{
// code...private void MyDelegateFunction() { } public MyClient() { RemoteObject oRO = null; // Get the remote object oRO.EvMyEvent += new MyDelegate(MyDelegateFunction); // Exception: /\* An unhandled exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll Additional information: Serialization will not deserialize delegates to non-public methods. \*/ }
}
Behind every great black man... ... is the police. - Conspiracy brother Blog[^]
-
Hello, I've got a very big problem with the .NET remoting. I've developed a synchronization library using .NET 2.0 that uses classes derived from
MarshalByRefObject
. These classes have public events which remote objects can subscribe to. Under the 2.0 framework, everything works like a charm. Now I have to port the library to .NET 1.x since my teachers want to be able to test and compile the code by themselves. I though that this would be a task of a few minutes. I guessed wrong. The runtime refuses to serialize the delegates. I've read something aboutRemotingSurrogateSelector
, but I can't find a thorough explanation about how the class should be used to handle this type of serialization. Does anybody know how I can subscribe to a remote event? Source example:// The delegate
public delegate void MyDelegate();
// The remote (server) object
class RemoteObject : System.MarshalByRefObject
{
// code...public event MyDelegate EvMyEvent;
}
// The client object
class MyClient
{
// code...private void MyDelegateFunction() { } public MyClient() { RemoteObject oRO = null; // Get the remote object oRO.EvMyEvent += new MyDelegate(MyDelegateFunction); // Exception: /\* An unhandled exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll Additional information: Serialization will not deserialize delegates to non-public methods. \*/ }
}
Behind every great black man... ... is the police. - Conspiracy brother Blog[^]
I don't know why this happens either, but making the delegate function (
MyDelegateFunction
) public solves the problem. Ugly, I know, but it works. I guess this is a bug and has been corrected in .NET 2.0 Regards Senthil _____________________________ My Blog | My Articles | WinMacro -
I don't know why this happens either, but making the delegate function (
MyDelegateFunction
) public solves the problem. Ugly, I know, but it works. I guess this is a bug and has been corrected in .NET 2.0 Regards Senthil _____________________________ My Blog | My Articles | WinMacro