配置GUI部署,放在同一目录下吗? C#
我正在编写一个 GUI 来配置用 C#.NET 3.5 编写的服务,它编辑嵌入式 SQLite 数据库,服务从中提取其设置。 GUI 是在一个单独的项目中开发的,我现在想集成它们。这是我第一次实现这样的事情,我不确定我该如何去做。
我是否只需将 GUI .exe 文件放在与服务相同的目录(bin?)中并为其提供数据库的位置?
I am writing a GUI to configure my service written in C#.NET 3.5, it edits an embedded SQLite database from which the service pulls its settings. The GUI is being developed in a seperate project and I am at the point where I would like to integrate them. It is my first time implementing someting like this and I am unsure how I go about it.
Do I simply place the GUI .exe file in the same directory (bin?) as the service and give it the location of the database?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,通常。但是,您必须请求提升,否则您将无法写入数据库。 UAC 阻止对 c:\program files 中的目录进行写访问。这没关系,毕竟用户正在修改特权服务的配置。您可能需要停止并启动服务才能使配置更改生效,这只能通过特权程序来完成。在 gui.exe 中嵌入清单,如 这篇文章。
先解决下一个问题:没有标准的 Windows 方法可以将 dbase 存储在服务和 GUI 都可以访问的位置,而无需提升。您必须编写一个安装程序来创建一个目录,为 gui 应用程序提供足够的权限,并允许服务在不依赖用户名的情况下找到该目录。
Yes, usually. You will however have to ask for elevation or you won't be able to write to the dbase. UAC prevents write access to the directories in c:\program files. Which is okayish, the user is after all tinkering with the configuration of a privileged service. And you probably need to stop and start the service to make the configuration change effective, something you can only do from a privileged program. Embed a manifest in gui.exe as explained in this post.
Pre-empting the next question: there is no standard Windows way to have to dbase in a location that's accessible to both the service and your gui without elevation. You'd have to write an installer that creates a directory that gives the gui app sufficient rights and allows the service to find the directory without relying on the user name.