J
Jasonkimberson
Currently I am having a problem creating a windows service that
monitors a mapped drive for events (using the FileSystemEventHandler).
The service complies but fails to start:
"The XMLWatcher service on Local Computer started and then stopped.
Some services stop automatically if they have no work to do, for
example, the Preformance Logs and Alerts service."
The Service has no problem starting if i point the folder to be
monitored to my local C drive, and it had no problem monitoring the
mapped network drive as a console app or windows app.
Any Help would be greatly appreciated.
Installer:
private void InitializeComponent()
{
this.serviceProcessInstaller1 = new
System.ServiceProcess.ServiceProcessInstaller();
this.serviceInstaller1 = new
System.ServiceProcess.ServiceInstaller();
//
// serviceProcessInstaller1
//
System.ServiceProcess.ServiceControllerPermissionAccess
this.serviceProcessInstaller1.Account =
System.ServiceProcess.ServiceAccount.User;
this.serviceProcessInstaller1.Password = "XXXXXXXX";
this.serviceProcessInstaller1.Username = "MyUserName";
//
// serviceInstaller1
//
this.serviceInstaller1.ServiceName = "XMLWatcher";
//
// ProjectInstaller
//
this.Installers.AddRange(new
System.Configuration.Install.Installer[] {
this.serviceProcessInstaller1,
this.serviceInstaller1});
}
Main Intializer
private void IntializeFileSystemWatcher()
{
//Create File System Watcher for XML files
fsWatcher=new System.IO.FileSystemWatcher("Y:\\","*.xml");
// Add event handlers for new XML files and change of existing XML
files.
fsWatcher.Changed += new FileSystemEventHandler(OnXMLFileChanged);
fsWatcher.Created += new FileSystemEventHandler(OnXMLFileCreated);
// Begin watching.
fsWatcher.EnableRaisingEvents = true;
fsWatcher1.EnableRaisingEvents = true;
}
monitors a mapped drive for events (using the FileSystemEventHandler).
The service complies but fails to start:
"The XMLWatcher service on Local Computer started and then stopped.
Some services stop automatically if they have no work to do, for
example, the Preformance Logs and Alerts service."
The Service has no problem starting if i point the folder to be
monitored to my local C drive, and it had no problem monitoring the
mapped network drive as a console app or windows app.
Any Help would be greatly appreciated.
Installer:
private void InitializeComponent()
{
this.serviceProcessInstaller1 = new
System.ServiceProcess.ServiceProcessInstaller();
this.serviceInstaller1 = new
System.ServiceProcess.ServiceInstaller();
//
// serviceProcessInstaller1
//
System.ServiceProcess.ServiceControllerPermissionAccess
this.serviceProcessInstaller1.Account =
System.ServiceProcess.ServiceAccount.User;
this.serviceProcessInstaller1.Password = "XXXXXXXX";
this.serviceProcessInstaller1.Username = "MyUserName";
//
// serviceInstaller1
//
this.serviceInstaller1.ServiceName = "XMLWatcher";
//
// ProjectInstaller
//
this.Installers.AddRange(new
System.Configuration.Install.Installer[] {
this.serviceProcessInstaller1,
this.serviceInstaller1});
}
Main Intializer
private void IntializeFileSystemWatcher()
{
//Create File System Watcher for XML files
fsWatcher=new System.IO.FileSystemWatcher("Y:\\","*.xml");
// Add event handlers for new XML files and change of existing XML
files.
fsWatcher.Changed += new FileSystemEventHandler(OnXMLFileChanged);
fsWatcher.Created += new FileSystemEventHandler(OnXMLFileCreated);
// Begin watching.
fsWatcher.EnableRaisingEvents = true;
fsWatcher1.EnableRaisingEvents = true;
}