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 开发者_JS百科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
Have a look in the Virtual Store 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.
精彩评论