I've downloaded and installed the '101 Visual Basic and C# Code Samples' from
http://www.microsoft.com/downloads/d...displaylang=en
I have used the 'Framework - Using the COM Port' sample, from a windows
forms application, and it works perfectly.
I have also use the 'Framework - How-To MSMQ' sample with no problems at all.
However when I use the MSMQ and windows service sample, and make it write
text to the COM port upon receiving a MSMQ message, the RS232 class, which
calls the Kernal32.dll comes back with an error.
I can call exactly the same code when not running inside a windows service,
and the error does not occur.
I've debugged the service, and have pinpointed when the error is occuring.
it's in the following method of the RS232.cs class
public void Write(byte[] Buffer)
When the following line is executed, the WriteFile function returns a zero
when called from the windows service, and a 1 when called from a forms
application.
Also, the 'Buffer', in both cases, is successfully sent to the COM port.
Someone please HELP, as I can't explain this!