最终用户是否可以在 Clickonce 部署后更改应用程序的 app.config?
我有一个应用程序将部署到这里的很多服务器和虚拟机上。此应用程序严重依赖于某些文件位置和 URL(根据其位于公司网络的哪个部分、是否需要域名、是否使用映射驱动器等,这些位置和 URL 可能会有所不同)。其中一些部署不能保证由我设置,有些将由其他最终用户设置。
我的解决方案是将这些值放入 app.config 文件中,以便在部署后,无论谁在服务器上设置应用程序,都只需更改适用于该服务器的 app.config 设置。
然后我发现 ClickOnce 部署可以帮助简化应用程序的部署和更新,这将使事情变得更加简单。
问题是我找不到可靠的方法来允许用户更改 app.config 中的值,并且最好在更新后保留这些值。根据我在网上找到的信息,如果您修改系统文件,它会认为该文件是旧的并下载该文件的最新版本,从而撤消对 app.config 的任何修改。新版本似乎部署到与以前版本完全不同的文件夹中,因此升级应用程序将完全消除以前的修改。
我已经在网上搜索过,但空手而归。这里有人对如何处理这个问题有什么建议吗?
I have an application that will be deployed onto quite a few servers and virtual machines here. This application heavily relies on certain file locations and URLs (which can be different depending on what part of the corporate network it's on, if it needs a domain name, if it uses a mapped drive, etc...). Some of these deployments are not guaranteed to be setup by me, some will be set up by other end users.
My solution was to put these into values in the app.config file, so that after deployment, whoever is setting the application up on a server has to just change the app.config settings for what works for that server.
I then found out about ClickOnce deployments which can help simplify the deployment and updating of the application, which will make things much simpler.
The problem is I cannot find a reliable way to allow users to change the values in app.config, and preferably keep those values post-updating. From what I have found on the web, if you modify a system file it will think the file is old and download the latest version of that file, thus undoing any modifications to app.config. It also seems like new versions are deployed into a totally different folder than previous versions, so upgrading the application will completely wipe out previous modifications.
I have searched the web and am coming up empty handed. Does anyone here have any suggestions on how to handle this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会将尽可能多的这些值放入数据库表中,然后为管理员提供一个前端来更改用户的设置。
I'd put as many of those values as you can in a database table, then give administrators a front-end to change their user's settings.
我已经通过使用用户范围的应用程序设置解决了这个问题,如此处所述。虽然这不是最好的方法(因为它是特定于用户的而不是特定于应用程序的),但由于我的应用程序仅由一个用户运行,所以这很好。
当用户更改其设置时,更改会在更新中持续存在。
I have solved this by using user scoped application settings, as described here. While it isn't the best method (since it's user specific not application specific), since my app is only run by one user this is fine.
When the user changes their settings, the changes persist across updates.