strange about settings in .net 2.0
created a simple windows service and a set up project for that .I uses
Settings feature in .net 2.0.It has a windowsservice1.settings file with a
user scope variable named “Settings1” with a default value “A”.
In the custom installation file I change the value of the settings1 variable
to a new value “ZB” and saves it.In the start event of the service I write
this value to a text file .But I get the old value “”A”.But this works with a
windows application.
Do you have any ideas on this?
protected override void OnAfterInstall(System.Collections.IDictionary
savedState)
{
System.Diagnostics.Debugger.Break();
base.OnAfterInstall(savedState);
global::WindowsService1.WindowsService1.Default.Setting1 = "ZB";
global::WindowsService1.WindowsService1.Default.Save();
}
protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
// System.Diagnostics.EventLog.WriteEntry("Application","started
");
System.IO.StreamWriter fs=
System.IO.File.CreateText(@"C:\ser.txt");
fs.Write(global::WindowsService1.WindowsService1.Default.Setting1);
fs.Flush();
fs.Close();
}
Date:Wed, 22 Aug 2007 23:34:01 -0700
Author:
|