VB.NET Windows 服务 My.Settings 的位置 - 设置
我有一个在 Visual Studio 2010 中构建的 VB.NET 解决方案。它由一个类项目、一个服务和一个安装项目组成。我已成功创建安装程序,并从安装项目的“Release”目录(在 Visual Studio 外部)运行该安装程序。它安装了该服务(与项目所在的同一台计算机上),并且该服务似乎运行良好。服务可执行文件与其依赖的一些 DLL 一起安装在 c:\program files (x86)\ 下的目录中。
该服务(实际上是我上面提到的类项目)使用 My.Settings 中的一些设置。据我所知,这些设置存储在项目目录中的 app.config 文件中,以及项目目录下的 My Project 目录中的 settings.settings 文件中。
安装程序不会安装这两个文件。但该服务只有在可以读取设置的情况下才能运行。那么我的服务从哪里获取这些设置呢?为了检查它是否仍然从 VS 项目目录中读取设置,我暂时重命名了该目录,但这并不影响服务的正确运行。
I have a VB.NET solution built in Visual Studio 2010. It consists of a class project, a service, and a setup project. I have successfully created a setup, and run the setup from the "Release" directory of the setup project (outside of Visual Studio). It installed the service (on the same machine as where the project is), and the service seems to be running fine. The service executable is installed in a directory under c:\program files (x86)\ along with some DLL's it is dependent of.
The service (actually the class project I mentioned above) uses some settings from My.Settings. As far as I know these settings are stored in a app.config file in the project directory, as well as in a settings.settings file in the My Project directory under the project directory.
Neither of these files are installed by the installer. But the service can only run if it can read the settings. So where does my service get these settings from? To check if it still reads the settings from the VS project directory, I have temporarily renamed that directory, but that didn't affect the correct operation of the service.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看看这条路。找到您的服务名称并向下导航,直到找到 user.config
C:\Windows\System32\config\systemprofile\AppData\Local\
user.config 仅具有您的服务已更新的设置,其他设置将位于服务安装路径上的 exe.config 中。
look on this path. Find your service name and navigate down until you find user.config
C:\Windows\System32\config\systemprofile\AppData\Local\
The user.config only has the settings that your service has updated the others will in the exe.config on the service install path.
查看虚拟存储 C:\Users\User_name\AppData\Local\VirtualStore\
Have a look in the Virtual Store C:\Users\User_name\AppData\Local\VirtualStore\
我自己找到了答案:类项目的设置存储在类项目 DLL 文件中。因此,在安装服务(使用此 DLL)后无法编辑它们。
I found the answer myself: the settings of the class project are stored within the class projects DLL-file. So they cannot be edited after the service (that uses this DLL) has been installed.