troubleshooting Question

Trying to handle OnComm event but have wrong signature ...

Avatar of XRCC
XRCC asked on
Visual Basic ClassicVisual Basic.NET
7 Comments1 Solution480 ViewsLast Modified:
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):

imports System.ServiceProcess

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

        With commTest
            .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
        End With
    End Sub

    Protected Overrides Sub OnStop()
        commTest.PortOpen() = False
    End Sub

    Private Sub commTest_OnComm(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles commTest.OnComm

         ' bunch of code in here

    End Sub

ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros