且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

2 部分 Windows 应用程序:“windows 服务";+ GUI 进行配置

更新时间:2022-12-21 11:02:44

您需要将 .exe 文件分开,一个用于服务,另一个用于 Windows 应用程序.您可以在 Visual Studio 中将这两个单独的 MSI 打包,这样做的好处是,如果您需要移动服务(无论出于何种原因),您无需同时打包 Windows 应用程序并将其留在安装服务的任何位置.

You will need to have to separate .exe files, one for the service and one for the windows application. You can package these are two separate MSIs within Visual Studio, the benefit here is that if you need to move the service (for whatever reason) you are not then also packaging up the Windows App and leaving it where ever you install the service.

您可以通过不同的方式让他们进行交流,而不会变得非常复杂.您可以按照您的建议从文本文件中读取,但这可能会导致锁定问题.当我不得不做类似的事情时,我在 SQL(或您希望的任何品牌的数据库)中创建了一个简单的数据库,并让 Windows 应用程序插入/更新配置选项到一个表,然后服务读取表格以获取其设置.

There are different ways you can have them communicate without getting massively complex. you could read from a text file, as you've suggested, but this could cause locking problems. When I've had to do similar I created a simple database in SQL (or any brand of database you wish), and have the Windows App insert / update configuration options to a table, and the service then reads the table to get its settings.