Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / March 2008

Tip: Looking for answers? Try searching our database.

My.Settings in Windows Service

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
matthewlowrance@gmail.com - 18 Mar 2008 17:14 GMT
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
René Jensen - 18 Mar 2008 20:40 GMT
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é

> 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.
[quoted text clipped - 24 lines]
> Thanks in advance for any help,
> Matt
Steve Gerrard - 19 Mar 2008 02:35 GMT
Option 1: copy the config before the update; run the update; copy back  the
config.

Option 2: don't do a reinstall just to update the service. Often you can just
stop the service, replace the exe, and start it again.

> 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.
[quoted text clipped - 24 lines]
> Thanks in advance for any help,
> Matt

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.