How do two WinForms applications communicate with each other?

王好 王 1 Reputation point
2021-05-24T13:11:27.85+00:00

I wrote two WinForms programs and installed them on two computers.How can one WinForms application get the other WinForms application to output some string on the interface, such as a string "hello"?

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,803 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Michael Taylor 45,091 Reputation points
    2021-05-24T14:59:45.117+00:00

    IPC is the only way as David mentioned. As far as IPC options it depends upon whether the apps are running on the same machine or across the network, internally or externally. Refer to the docs he mentioned for the options available and determine the one(s) to use based upon your needs. For local machines you'll probably use named pipes, for remote machines then perhaps something simple like a TCP server. Across the INet then you're looking at REST. WCF would be an option as well but be aware that WCF Server is not supported in .NET Core/5+ so I would not recommend going that route.

    0 comments No comments

  2. Sam of Simple Samples 5,516 Reputation points
    2021-05-24T20:42:50.737+00:00

    If you have an existing WinForms application then I assume you are not using .NET 5 so you can use Windows Communication Foundation (WCF). If you are using .NET 5 or above for WinForms then you cannot use WCF; gRPC is the alternative and it does not work for .Net prior to .Net 5. WCF has been designed as a high-level interface to most options for communications among applications.

    If you do not want a client and server then that would be what is called Peer-to-Peer Networking.

    0 comments No comments