AxMSComm

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Anyone uses MSComm in .net? I try to dynamically create the MSComm, without
dragging the control to the form, but got the InvalidActiveXStateException.

Dim cmp As AxMSCommLib.AxMSComm
cmp = New AxMSCommLib.AxMSComm
CType(Me.ScanSerial, System.ComponentModel.ISupportInitialize).BeginInit()
cmp.ContainingControl = Me
cmp.Enabled = True
cmp.Name = "Serial"
'cmp.OcxState =
CType(Me.ScanSerial, System.ComponentModel.ISupportInitialize).EndInit()

Any idea how to solve it or what causes the problem? Is the BeginInit() and
EndInit() needed?

thanks
eugene
 
Hi,

You cannot use MSComm dynamically under .NET. The COM interface
implementation requires that it be sited.

However, you can download DesktopSerialIO.dll from my homepage (syntax is
similar to that of MSComm) -- and it is free, or use the Sax Communications
Community Edition Serial Control that is part of the Microsoft Visual Basic
..NET Resource Kit (also free). There are other serial classes available
online.

One advantage to my dll (an other .NET implementations) is that they are
standalone and don't require MSComm or the wrapper dll that .NET builds.
Another is that deployment is simple. Just copy the dll along with your
exe.

Dick

Dick

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See
www.mabry.com/vbpgser4 to order.
 
thanks, so the mscomm be be contained in the form. btw, what is meant by
sited, why is it so?
 
Hi,
thanks, so the mscomm be be contained in the form. btw, what is meant by
sited, why is it so?
<<

Sited means added to the form from the ToolBox (and accessed from the
STAThread for that form). Why? Because... That's the way interoperability
for ActiveX controls in .NET was designed. Fighting with it is like
deciding that the Sun should come up in the West. Maybe it should, but it
doesn't.

Dick

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004. See
www.mabry.com/vbpgser4 to order.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top