Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. .NET 1.x remoting hell!

.NET 1.x remoting hell!

Scheduled Pinned Locked Moved C#
csharpcomsysadmintoolsjson
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bob Stanneveld
    wrote on last edited by
    #1

    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 about RemotingSurrogateSelector, 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[^]

    S 1 Reply Last reply
    0
    • B Bob Stanneveld

      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 about RemotingSurrogateSelector, 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[^]

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      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

      B 1 Reply Last reply
      0
      • S S Senthil Kumar

        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

        B Offline
        B Offline
        Bob Stanneveld
        wrote on last edited by
        #3

        Hi, Thanks for the reply. It's ugly indeed. It's that I'm not a strict OO purist... I hope that everybody moves to the .NET 2.0 framework soon.. Behind every great black man...             ... is the police. - Conspiracy brother Blog[^]

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups