My.Settings in Windows Service

  • Thread starter Thread starter matthewlowrance
  • Start date Start date
M

matthewlowrance

I have written a windows service using VB 2005 (.Net 2.0). I have a
couple of settings that I need to store, just some paths.

I put them in the Application settings section and then manually edit
the file and start the service and everything works fine. However
when a new version is installed the file gets overwritten and the
settings are lost.

I tried making them user settings and using the "ShouldUpgrade"
setting trick, but it appears that they still get overwritten. I
assume that with a service the .config stored in the execution
directory is the only one that is created? As a result it is always
overwritten by a new version?

Is there a better way to handle this? I guess I can just create my
own config file and not use application settings, but I hate to do
that. I am going to be working on another service that will require a
large number of settings to be stored, using my.settings would be
convenient for that project, but if the settings are overwritten after
a new install I might not want to do it.

Now that I think about it, even if I create my own file, which would
be included in the installation, it would overwrite as well. I guess
it boils down to, is there a better way to handle settings for a
windows service that won't get overwritten?

Thanks in advance for any help,
Matt
 
Hi, i'm no expert, but can't you alter the installer for the windows
service to not overwrite an existing .config file in one exist?

BR

René
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

My.Settings problem 1
My.Settings Questions 31
Using My.Settings and forms 4
my.Settings 2
My.Settings magic 8
My.Settings with roaming profiles 2
Using My.settings in VB2005 7
My.Settings files 7

Back
Top