简体   繁体   中英

Location of VB.NET Windows Service My.Settings - settings

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.

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM