Please post the console application code, we can't help you without it .
Willy.
| Hey Dick,
|
| The Timer question is solved with the System.Timers.Timer so that is not
a
| problem but the SerialPort seems to be a bigger problem.
|
| I've created a test-service wich only a SerialPort as content.
| The serial port is picked from the toolbox in my service component, the
| baudrate etc is set with the property's in the designer.
| The SerialPort is constructed in the defaul component initialise of the
| service constructor where I also set a public counter to 0..
| In the OnStart I do an SerialPort.Open().
| In the OnStop I do the SerialPort.Close() and write the content of my
public
| counter to the eventlog,
| In the eventhandler I incr. the public counter.
|
| When now I send a string tot the serial port the counter is not
incremented
| (I have tried to trow an exeption to but noting happens)
|
| Next I have included a timer of 1000 ms testing the IsOpen from the
| SerialPort and writing the result of my public counter to the eventlog.
the
| port is ans stays open but the counter stays to 0
|
| When I use the same code in a WindowsForm app all works fine.
|
| When I try to use the SerialPort in a console application, It does not
work
| neighter.
|
| Strange but true, I searched the whole internet for somone or somthing
about
| the SerialPort and the WindowsService but all who ever published something
| in thes direction used a P/Invoke and the Win32 kernel.
|
| So far the story here.
|
| Greets
|
| Jean Paul
|
| "Dick Grier" <
[email protected]> schreef in bericht
| | > Hi,
| >
| > I do not know. It "should work," but I haven't written a service under
VS
| > 2005 to test it. I will do that sometime soon, just as an experiment.
| >
| > However, it is perfectly acceptable to use System.Timers.Timer to poll.
| > You will not (IMO) incure an perfomance degredation, and very little
extra
| > overhead.
| >
| > Dick
| >
| > --
| > Richard Grier, MVP
| > Hard & Software
| > Author of Visual Basic Programmer's Guide to Serial Communications,
Fourth
| > Edition,
| > ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised
March
| > 2006.
| > See
www.hardandsoftware.net for details and contact information.
| >
|
|