Link to home
Start Free TrialLog in
Avatar of keymac
keymacFlag for Australia

asked on

Windows Service with MSCommLib

I have created a windows service in VB.Net that uses the MSCommLib namespace. I then instantiate as per below

MyComm = New MSCommLib.MSComm
       
        MyComm.CommPort = 4
        MyComm.DTREnable = True
        MyComm.EOFEnable = False
        MyComm.Handshaking = HandshakeConstants.comNone
        MyComm.InBufferSize = 1024
        MyComm.InputLen = 0
        MyComm.InputMode = InputModeConstants.comInputModeText
        MyComm.OutBufferSize = 512
        MyComm.ParityReplace = "?"
        MyComm.RThreshold = 0
        MyComm.RTSEnable = False
        MyComm.SThreshold = 0
        MyComm.Settings = "9600,n,8,1"

        MyComm.PortOpen = True


I have successfully installed and start the service on my laptop but when I install it on another server that is running either Windows Server 2003 or Windows Small Business Server 2011, I get this error when trying to start the service.

Application: MyDAService.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Runtime.InteropServices.COMException
Stack:
   at System.RuntimeTypeHandle.CreateInstance(System.RuntimeType, Boolean, Boolean, Boolean ByRef, System.RuntimeMethodHandleInternal ByRef, Boolean ByRef)
   at System.RuntimeType.CreateInstanceSlow(Boolean, Boolean, Boolean)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean, Boolean, Boolean, Boolean)
   at System.Activator.CreateInstance(System.Type, Boolean)
   at MyDAService.Service1..ctor()
   at MyDAService.Service1.Main()
ASKER CERTIFIED SOLUTION
Avatar of Randy Downs
Randy Downs
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Gautham Janardhan
Gautham Janardhan

I assume tht these com objects are available in the server?

Does the user behalf of whom the service is running have access to create the com object?
Avatar of keymac

ASKER

How do I confirm that the server has the objects available
If you need to use the serial port, there is a completed managed version that doesn't use COM, and is part of the .NET framework.

System.IO.SerialPort

Communication on a serial port in NET 2.0
http://www.codeproject.com/Articles/17190/Communication-on-a-serial-port-in-NET
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.