I have a current software product written in C# WinForms that I'm migrating to WPF .NET 5.0. I've almost got it all migrated, but one of the last projects to migrate is the remoting support for the app. This is intended for remote control from a client in an intranet, NOT Internet.
The current version of the product uses .NET Remoting, however, I sadly have found that this is not supported in .NET 5.0.
I've seen something about gRPC, but can't find anything to show me how to implement or whether there might be something more similar to .NET Remoting to use so that there are minimal changes required.
Thanks in advance for your help!
@Fildor, this isn't really an answer, perse, just posting what I ended up doing for a simplistic approach, rather than leveraging a remoting framework. My remoting implementation always runs on a private network or over a corporate VPN, so security isn't an issue. Thus, I can take a simplistic approach.
What I finally ended up implementing is a simple TCP/IP Socket implementation using TcpClient class and TcpListener that passes Json strings to represent a command and the response objects defined as classes. This class includes server API methods, each of which map to the defined API.
I created a class that inherits from TcpClient (RemoteClientSocket) for the client and another that inherits from TcpListener (RemoteListener) on the server.This class includes client API methods, each of which map to defined API.
I defined an enum, CommandType , that includes types for each remote command.
The RemoteClientSocket class includes method, SendCommand() that is invoked by each of the client API methods after instantiating a RemoteClientCommand object, this method takes a RemoteClientCommand argument.
The RemoteListener class includes methods for each of the remote commands defined in the CommandType enum.
I then created RemoteClientCommand class that is serialized into a Json string and sent from the client and deserialized by the RemoteListener object, which maps to the server command. I then created a RemoteClientResponse class that is serialized to a Json string, which is returned to the client. Each class includes a Serialize() and DeSerialize() method to serialize/deserialze to/from a Json string that is actually sent over the TCP/IP connection.
Lastly, add methods to the RemoteClientSocket class for each of the commands that populates the CommandArgs object array to send to the server and add methods to the RemoteListener class that that executes the server method corresponding to the CommandType contained in the RemoteClientCommand object.
After the RemoteListener executes the command, it instantiates a new RemoteCommandResponse object and populates the CommandReturn object and the CommandOutParams object array, calls Serialize() on the RemoteCommandResponse object and sends that Json string in response over the TCP/IP connection.
When the RemoteClientSocket receives the response, it calls DeSerialize() on the Json response string and unpackages the CommandReturn object, if any, and the CommandOutParams, if any, before returning to from the client method.
Here is the code for the RemoteListener:
Here is the code for the RemoteClientSocket: