Click here to Skip to main content
16,013,322 members
Home / Discussions / C#
   

C#

 
GeneralRe: error handling Pin
dcof2-Nov-11 4:13
dcof2-Nov-11 4:13 
GeneralRe: error handling Pin
fjdiewornncalwe2-Nov-11 4:21
professionalfjdiewornncalwe2-Nov-11 4:21 
AnswerRe: error handling Pin
Luc Pattyn2-Nov-11 4:25
sitebuilderLuc Pattyn2-Nov-11 4:25 
AnswerRe: error handling Pin
AditSheth1-Nov-11 18:32
AditSheth1-Nov-11 18:32 
GeneralRe: error handling Pin
Pete O'Hanlon1-Nov-11 21:04
mvePete O'Hanlon1-Nov-11 21:04 
GeneralRe: error handling Pin
BobJanova1-Nov-11 23:55
BobJanova1-Nov-11 23:55 
AnswerRe: error handling Pin
V.2-Nov-11 0:22
professionalV.2-Nov-11 0:22 
QuestionWin service jumps out Pin
suunker1-Nov-11 10:01
suunker1-Nov-11 10:01 
Hey,

I've been stuck with this problem quite a while now, so I figured maybe you can help me?
I have a program that is being started by creating a new instance of a class, and then call it's start method, that is starting a timer. When developing, I've been using a win forms GUI to press the button to start, and that has been working fine. Now when the program is done and works fine, I want to make it a win service. So I simply added a win service to the project. But, even though the service does exatly the same thing as the forms GUI, the program doesn't start. This is the code..
C#
//The service
private FileWatcher fw; 
public MyService()
{
InitializeComponent();
}

protected override void OnStart(string[] args)
{
fw = new FileWatcher();
fw.Start();
}

protected override void OnStop()
{
fw.Stop(); 
}

//The class that is beeing initialized

public FileWatcher()
{
_archiveFolder = "D:\\Archive\\";
_errorFolder = "D:\\Error\\";
_fileWatcherInputFolder = "C:\\Input\\";
_processFolder = "C:\\Process\\";

_archiveFolder = "C:\\PMI\\Archive";
_errorFolder = "C:\\PMI\\Error\\";
_fileWatcherInputFolder = "C:\\PMI\\Input";
_processFolder = "C:\\PMI\\Process";
_PMIRepository = new PMIRepository();
_ParserController = new ParserController(_archiveFolder, _errorFolder, _fileWatcherInputFolder, _processFolder);
}

public void Start()
{

try
{

// Log.Information("Starting FileWatcher " + DateTime.Now.ToString());
if (!Directory.Exists(_archiveFolder))
Directory.CreateDirectory(_archiveFolder);
if (!Directory.Exists(_errorFolder))
Directory.CreateDirectory(_errorFolder);
_fileCheckTimerBatch = new System.Timers.Timer { AutoReset = false, Interval = 1000 };
_fileCheckTimerBatch.Elapsed += FileCheckTimer_Batch_Elapsed;
_fileCheckTimerBatch.Start();

}
catch (Exception ex)
{
}

}
public void Stop()
{
_fileCheckTimerBatch.Stop(); 
}

When I step into the program, I can see it reaches the Start() method and walks down to _fileCheckTimerBatch.Start(), but then it jumps out. The debugger just walks back to the Service class and stops the program. What have I done wrong? I even started a whole new service project and copied all the filewatcher DLL files to the new project, but still the same problem.

Thanks
Sunker
AnswerRe: Win service jumps out Pin
DaveyM691-Nov-11 11:22
professionalDaveyM691-Nov-11 11:22 
AnswerRe: Win service jumps out Pin
PIEBALDconsult1-Nov-11 13:32
mvePIEBALDconsult1-Nov-11 13:32 
QuestionTheming Custom Controls At Design-Time Pin
Matt U.1-Nov-11 8:48
Matt U.1-Nov-11 8:48 
AnswerRe: Theming Custom Controls At Design-Time Pin
BobJanova2-Nov-11 0:00
BobJanova2-Nov-11 0:00 
Questioncreate DSN for oracle programatically Pin
KKSharma31-Oct-11 22:56
KKSharma31-Oct-11 22:56 
AnswerRe: create DSN for oracle programatically Pin
PIEBALDconsult1-Nov-11 2:50
mvePIEBALDconsult1-Nov-11 2:50 
QuestionHelp with GetProcesses Pin
CCodeNewbie31-Oct-11 13:03
CCodeNewbie31-Oct-11 13:03 
AnswerRe: Help with GetProcesses Pin
Pete O'Hanlon31-Oct-11 20:46
mvePete O'Hanlon31-Oct-11 20:46 
GeneralRe: Help with GetProcesses Pin
CCodeNewbie31-Oct-11 23:29
CCodeNewbie31-Oct-11 23:29 
GeneralRe: Help with GetProcesses Pin
Pete O'Hanlon1-Nov-11 0:46
mvePete O'Hanlon1-Nov-11 0:46 
AnswerRe: Help with GetProcesses - Sort of Solved Pin
CCodeNewbie2-Nov-11 12:11
CCodeNewbie2-Nov-11 12:11 
QuestionAudio processing Pin
Guy00731-Oct-11 8:09
Guy00731-Oct-11 8:09 
AnswerRe: Audio processing Pin
phil.o31-Oct-11 8:44
professionalphil.o31-Oct-11 8:44 
QuestionUnique values in list Pin
nitin_ion31-Oct-11 0:09
nitin_ion31-Oct-11 0:09 
AnswerRe: Unique values in list Pin
Pete O'Hanlon31-Oct-11 0:57
mvePete O'Hanlon31-Oct-11 0:57 
GeneralRe: Unique values in list Pin
nitin_ion31-Oct-11 1:01
nitin_ion31-Oct-11 1:01 
GeneralRe: Unique values in list Pin
Not Active31-Oct-11 2:06
mentorNot Active31-Oct-11 2:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.