Search code examples
c#wcf

WCF replacement for cross process/machine communication


I am working on a C# application that contains multiple windows services that will need to communicate with each other to pass data around. These services may be on the same machine but they could be remote. I looked into using WCF for this purpose but it seems like WCF is too heavy and has a lot of extra configuration that, to me, seems unnecessary (.NET 3.5 is a requirement here, I know that .NET 4 simplified this)

So my question is, what would be the best replacement to WCF, besides the deprecated .NET Remoting that provide this functionality?


Solution

  • I have been using PInvoke to access the Windows RPC runtime for nearly 8 years. It's wicked fast and very reliable as far as a transport goes. When combined with a fast serializer like protobuf-csharp-port the resulting communications are rock solid and very fast.

    So to build this from the ground-up this requires three parts:

    1. Google's Protocol Buffers (protobuf-csharp-port) for serialization.
    2. My own CSharpTest.Net.RpcLibrary for the transport.
    3. A bit of glue code to put them together from protobuf-csharp-rpc.

    These are all available on NuGet in the following packages: Google.ProtocolBuffers, CSharpTest.Net.RpcLibrary, and Google.ProtocolBuffers.Rpc.

    The following is a quick run-down on getting started:

    1. define a set of messages and a service using the Google Protocol Buffer Language.

    2. Once you have that defined you will run ProtoGen.exe to generate the service stubs and messages in C#. Be sure to add the "-service_generator_type=IRPCDISPATCH" to generate the correct service code.

    3. Now that you have the generated source files add them to a project and reference the three assemblies from the packages listed above.

    4. Lastly take a look at the sample client/server code on the protobuf-csharp-rpc project page. Replace the "SearchService" with your service name, and you should be ready to run.

    5. Optionally change the configuration of the RPC client/server. The example shows the use of LRPC which is local-host only; however the DemoRpcLibrary.cs source file show TCP/IP and Named Pipes as well.

    You can always email me (roger @ my user name) for any further information or examples.

    Update

    I wrote a quick startup guide: WCF replacement for cross process/machine communication.