如何在WPF C#中创建一个简单的客户端服务器应用程序

时间:2021-10-28 21:02:38

I would like to create a client server application in WPF. I dont know if this application is as same as console application. Because there is XAML part in WPF. That's why I'm asking here.

我想在WPF中创建一个客户端服务器应用程序。我不知道这个应用程序是否与控制台应用程序相同。因为WPF中有XAML部分。这就是我在这里问的原因。

Can you give some sample code for this application ?

你能为这个应用程序提供一些示例代码吗?

I will send some text or file from one machine to another machine, I think I should run server part in other machine and client part in my machine? but first I want to try both in my machine.

我会将一些文本或文件从一台机器发送到另一台机器,我想我应该在我的机器中的其他机器和客户机部分运行服务器部分?但首先我想在我的机器上尝试这两种方法。

Thank you.

2 个解决方案

#1


0  

Regarding the third paragraph, when developing client-server applications, it is common to debug both the client and the server on the same machine. If you're using Visual Studio, you can do this by creating the client and server applications as separate projects in the same solution.

关于第三段,在开发客户端 - 服务器应用程序时,通常在同一台机器上调试客户端和服务器。如果您使用的是Visual Studio,则可以通过在同一解决方案中将客户端和服务器应用程序创建为单独的项目来完成此操作。

Sample code for an entire client-server application is beyond the scope of a * question or answer; you'd do better to ask a single question focusing on a specific aspect of a problem you're currently facing. Once you've resolved that, return to the site and ask a question about the next problem.

整个客户端 - 服务器应用程序的示例代码超出了*问题或答案的范围;你最好问一个问题,关注你目前面临的问题的一个特定方面。一旦您解决了这个问题,请返回该网站并询问有关下一个问题的问题。

Also, questions that ask "how can I learn something to help me solve this problem" are generally received far more favorably than questions that ask "please solve my problem for me."

此外,问题“我怎样才能学到一些东西来帮助我解决这个问题”通常比那些问“请为我解决问题”的问题更有利。

#2


0  

For simplified implementation you will need WCF which will makes the communication between client server easier. There are lot of good tutorials online on WCF/WPF.

为简化实现,您将需要WCF,这将使客户端服务器之间的通信更容易。在WCF / WPF上有很多很好的在线教程。

#1


0  

Regarding the third paragraph, when developing client-server applications, it is common to debug both the client and the server on the same machine. If you're using Visual Studio, you can do this by creating the client and server applications as separate projects in the same solution.

关于第三段,在开发客户端 - 服务器应用程序时,通常在同一台机器上调试客户端和服务器。如果您使用的是Visual Studio,则可以通过在同一解决方案中将客户端和服务器应用程序创建为单独的项目来完成此操作。

Sample code for an entire client-server application is beyond the scope of a * question or answer; you'd do better to ask a single question focusing on a specific aspect of a problem you're currently facing. Once you've resolved that, return to the site and ask a question about the next problem.

整个客户端 - 服务器应用程序的示例代码超出了*问题或答案的范围;你最好问一个问题,关注你目前面临的问题的一个特定方面。一旦您解决了这个问题,请返回该网站并询问有关下一个问题的问题。

Also, questions that ask "how can I learn something to help me solve this problem" are generally received far more favorably than questions that ask "please solve my problem for me."

此外,问题“我怎样才能学到一些东西来帮助我解决这个问题”通常比那些问“请为我解决问题”的问题更有利。

#2


0  

For simplified implementation you will need WCF which will makes the communication between client server easier. There are lot of good tutorials online on WCF/WPF.

为简化实现,您将需要WCF,这将使客户端服务器之间的通信更容易。在WCF / WPF上有很多很好的在线教程。