   [.net] .NET Remoting, anyone with experience?
  I'm currently looking into remoting, and see if it's easier to use than writing my own protocol.However, I do have a feel questions. Is the purpose of Remoting similar to that of Java's RMI(Remote Method Invocation)? In Java, you create an interface, implement it server-side and provide the client with it. The client calls functions on interface and these get re-routed to the server.I want a similar system. I'm writing a card game which you play over a network. I looked into Remoting, and it looks usefull in this case. I want to have a global Game object, and when a client connects, it will call functions on this object.Is remoting usefull for this kind of things? So I can have a Game object(Shared accross all clients) and a Player object(New instances per player).The player objects keep track of the cards, and the client calls functions on the server object on which cards are played, etc.Is Remoting a feaseble option for this? Or did I get the wrong idea from Remoting? I did some a simple example, but it doesn't appear to be using inter-client communications.Toolmaker   
  In my personal experience, .NET Remoting is more trouble than it's worth.  I suppose if you have an extremely complex object hierarchy and you wanted to take advantage of .NET's transparent proxy objects to do communication, then it might be worth the time.Other than that, I don't think so.  And, also, without quite a bit of extra work, event's (delegates) do not work very well with remoting.  In the end, you have to write an abstract shim class for anything that needs to use remoted events.  I found it much simpler to write my own protocol.-Dave   ;  I already created several remoting-services at work and besides the already mentioned event-problems it worked quite fine for me. The simplest intuitive way to create a single shared instance of a class is to use the RemotingServices.Marshal method. But never forget to override the InitializeLifetimeService() method within your singleton-object so it returns "null". Otherwise it will get destroyed after all the lease times of the clients expired.Just look at the SDK-Docs for the RemotingServices.Marshal methods for getting an idea on how it works.   ;  Right now, I got it working, and it's quite easy to use. Pretty similar to how RMI works in Java.My current problem is propagating event messages to the other side. I started out with using Events and found out the hardway it doesn't work. So I need a different solution, so I can actually call functions client side.I probably need to implement some sort of interface client side, and pass this to the server, and then call them on the server. A bit much more hassle, but it probably works.Toolmaker   ;Quote:Original post by ToolmakerMy current problem is propagating event messages to the other side. I started out with using Events and found out the hardway it doesn't work. So I need a different solution, so I can actually call functions client side.You can use events with remoting, but there's a little more work involved. This KB article is a good place to start.;  Also, this is a good place to go for resources on remoting. Ingo Rammer wrote *the* book on the subject.   ;  Right now, I'm using the exmaple you provided using the KB article(Arild is one o persons who helped me time after time. Thanks Arild [grin]). However, I'm getting an exception:"Type System.DelegateSerializationHolder and the types derived from it (such as System.DelegateSerializationHolder) are not permitted to be deserialized at this security level."The exception is thrown on this line:server.ChatEvent += new ChatEventHandler(callback.ChatCallback);I have NO idea on how to solve that. Anyone has an idea on how I can provide my application(s) with the correct security rights?Toolmaker   ;  Where are you running it from? If it's run from a local drive (instead of a network drive), it should by default have full trust.   ;  Both are the client and the server are running locally, not in the same directory tho.I'm using the 2.0 framework, in case it helps. I'll google for the error.Toolmaker   ;  I really had it with this. The delegates require ALOT of additional work to setup, and don't appear to work without some crazy System.Security.AllowPartiallyTrustedCallersAttribute set to true(Which I have no idea how to do).I'm thinking of just going with interfaces and passing those to the server.In other words, for a simple chat client:    public interface IClient    {   void UsedJoined(string name);   void Chat(string name, string message);   void UserLeft(string name);   void Broadcast(string message);    }When I connect to the server, I'll do:IChatServer server = (IChatServer)Activator.GetObject(typeof(IChatServer), "tcp://localhost:4000/ChatServer");server.Join(this);Console.WriteLine("Type 'exit' to quit\r\n");while (true){    string line = Console.ReadLine();    if (line == "exit");   break;    else   server.Chat(line);}And then override the functions locally to do whatever action is required. Will work fine.Toolmaker   