Не получается запустить службу Windows - C#
Формулировка задачи:
Добрый день! Создал приложение для мониторинга директорий в Windows. Затем переделал его в службу. При попытке запуска службы выходит ошибка 1053 (ошибка времени запуска). Гуглил похожие темы, пытался сделать, как там написано, но пока что ничего не выходит. Помогите разобраться. Вот кусок кода:
Далее идет описание других методов...
public partial class Service1 : ServiceBase
{
public Service1()
{
this.AutoLog = false;
InitializeComponent();
}
static bool flag = true;
static List<FileSystemWatcher> elements = new List<FileSystemWatcher>();
static List<Thread> threads = new List<Thread>();
static bool office_option = true;
static bool work = true;
protected override void OnStart(string[] args)
{
System.IO.File.Delete(@"C:\Audit\one.txt");
File.Copy(@"C:\Audit\input.txt", @"C:\Audit\input2.txt");
string[] lines = System.IO.File.ReadAllLines(@"C:\Audit\input2.txt");
System.IO.File.Delete(@"C:\Audit\input2.txt");
// System.IO.File.Delete(@"C:\Audit\input2.txt");
List<string> directories = new List<string>();
for (int i = 0; i < lines.Length; i++)
{ directories.Add(lines[i]); }
for (int i = 0; i < lines.Length; i++)
{
directories.Add(lines[i]);
Thread thread = new Thread(create_new_watcher);
threads.Add(thread);
(threads.Last()).Name = "Thread " + (threads.Count);
(threads.Last()).Start(directories[i]);
}
FileSystemWatcher watcher = new FileSystemWatcher("C:/Audit");
watcher.Filter = "*.txt";
watcher.NotifyFilter = NotifyFilters.FileName;
watcher.Created += new FileSystemEventHandler(tmp_search);
watcher.EnableRaisingEvents = true;
while (work) { Thread.Sleep(200); }
}
protected override void OnStop()
{
work = false;
}Решение задачи: «Не получается запустить службу Windows»
textual
Листинг программы
bool flag = true;
while(flag) {}