.NET Remoting design question
-
12 martie 2012 15:54
Hi
I have a server application which needs a simple console program to issue commands to the server. I am completely new to .NET Remoting but I thought this could be the right way to establish communication between console and server.
So I have defined a Marshal object in a shared DLL.
But... How can I implement server side logic without having to put all server logic in the shared DLL? So far I have made following design:
public class ClientRequestHandler : MarshalByRefObject, IClientRequestHandler { private static IClientRequestHandler serverClientRequestHandler; public static void InitializeServerClientRequestHandler(IClientRequestHandler clientRequestHandler) { serverClientRequestHandler = clientRequestHandler; } public bool Start(string serviceName) { if(serverClientRequestHandler == null) { throw new Exception("ServerClientRequestHandler not assigned"); } return serverClientRequestHandler.Start(serviceName); } public bool Stop(string serviceName) { if (serverClientRequestHandler == null) { throw new Exception("ServerClientRequestHandler not assigned"); } return serverClientRequestHandler.Stop(serviceName); } public string[] ShowStatus() { return new[] {"THIS", "IS", "TESTING"}; } }
The idea is that
IClientRequestHandler
is an interface that defines the command being processed on the server and thus, the marshall objects implement it as well. Since I have no influence on object creation, my thought was to initialize the static
serverClientRequestHandler
in the following manner:
TcpChannel tcpChannel = new TcpChannel(remotingPort); ChannelServices.RegisterChannel(tcpChannel); ClientRequestHandler.InitializeServerClientRequestHandler(new MyServerClientRequestHandler(....)); RemotingConfiguration.RegisterWellKnownServiceType(Type.GetType("ProcessRunnerCommons.ClientRequestHandler,object"), remotingName, WellKnownObjectMode.Singleton);
It doesnt strike me as a good way - but it is the only way I can think of.
So I hoped for some input from you guys.
TIA
/Søren
Best regards Soeren D.
Toate mesajele
-
13 martie 2012 08:54
Hi Soeren,
sorry, I don't get you.
Anyway, if your issue is related to System.net namespace, please refer to this forum: http://social.msdn.microsoft.com/Forums/en/ncl/threads
Have a nice day.
Ghost,
Call me ghost for short, Thanks
To get the better anwser, it should be a better question.- Marcat ca răspuns de Soeren Dalby 13 martie 2012 09:24
-
13 martie 2012 09:24
Yes, I understand, I am to confused to even ask the question.
I close it for now because I plan to switch to WCF
Best regards Soeren D.