VB.NET Windows 服务 My.Settings 的位置 - 设置

发布于 2024-12-05 16:55:41 字数 459 浏览 1 评论 0原文

我有一个在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

烟雨扶苏 2024-12-12 16:55:41

看看这条路。找到您的服务名称并向下导航,直到找到 user.config
C:\Windows\System32\config\systemprofile\AppData\Local\
user.config 仅具有您的服务已更新的设置,其他设置将位于服务安装路径上的 exe.config 中。

Protected Overrides Sub OnStart(ByVal args() As String)
    My.Settings.TimerMsInterval = thisTimer.Interval
    My.Settings.MoreMsgs = My.Settings.MoreMsgs
    My.Settings.LastTime = My.Settings.LastTime
    My.Settings.Save()
EventLog.WriteEntry("Startup Parameters: TimerMsInterval: LastTime: MoreMsgs " & thisTimer.Interval.ToString & " : " & My.Settings.LastTime & " : " & My.Settings.MoreMsgs)
End Sub

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.

Protected Overrides Sub OnStart(ByVal args() As String)
    My.Settings.TimerMsInterval = thisTimer.Interval
    My.Settings.MoreMsgs = My.Settings.MoreMsgs
    My.Settings.LastTime = My.Settings.LastTime
    My.Settings.Save()
EventLog.WriteEntry("Startup Parameters: TimerMsInterval: LastTime: MoreMsgs " & thisTimer.Interval.ToString & " : " & My.Settings.LastTime & " : " & My.Settings.MoreMsgs)
End Sub
一杆小烟枪 2024-12-12 16:55:41

查看虚拟存储 C:\Users\User_name\AppData\Local\VirtualStore\

Have a look in the Virtual Store C:\Users\User_name\AppData\Local\VirtualStore\

半寸时光 2024-12-12 16:55:41

我自己找到了答案:类项目的设置存储在类项目 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文