A bit of background: I am an occasional programmer and therefore like VB6 for simplicity. But this time I am using VB.NET (2002 sp1) to write an app that will use the serial port.
I was able to create a standard form based exe with the VB6 MSComm32.ocx which worked fine. But this was just a test ... what I really need is a service. So I created a new VB.Net Service app and began porting over code without the form (don't need any UI).
I think I am very close but my event handler subroutine is saying that it cannot handle the OnComm event because they do not have the same signatures. The event handler subroutine is copied right from the form based version of this app which works.
Here is the code (which doesn't do much ... the 'handle' error is compile time):
Public Class Service1
Public WithEvents commTest As MSCommLib.MSComm = New MSCommLib.MSCommClass()
Protected Overrides Sub OnStart(ByVal args() As String)
If commTest.PortOpen() Then commTest.PortOpen() = False
.CommPort = 1
.DTREnable = True
.EOFEnable = False
.Handshaking = MSCommLib.HandshakeConstants.comNone
.InBufferSize = 1024
.OutBufferSize = 512
.RThreshold = 1
.SThreshold = 0
.Settings = "9600,n,8,1"
.PortOpen() = True
Protected Overrides Sub OnStop()
commTest.PortOpen() = False
Private Sub commTest_OnComm(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles commTest.OnComm
' bunch of code in here