keymac
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.comInpu tModeText
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.InteropServ ices.COMEx ception
Stack:
at System.RuntimeTypeHandle.C reateInsta nce(System .RuntimeTy pe, Boolean, Boolean, Boolean ByRef, System.RuntimeMethodHandle Internal ByRef, Boolean ByRef)
at System.RuntimeType.CreateI nstanceSlo w(Boolean, Boolean, Boolean)
at System.RuntimeType.CreateI nstanceDef aultCtor(B oolean, Boolean, Boolean, Boolean)
at System.Activator.CreateIns tance(Syst em.Type, Boolean)
at MyDAService.Service1..ctor ()
at MyDAService.Service1.Main( )
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.comInpu
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.InteropServ
Stack:
at System.RuntimeTypeHandle.C
at System.RuntimeType.CreateI
at System.RuntimeType.CreateI
at System.Activator.CreateIns
at MyDAService.Service1..ctor
at MyDAService.Service1.Main(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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.
Does the user behalf of whom the service is running have access to create the com object?