Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Serial Port

44 views
Skip to first unread message

Thiago Guedes

unread,
Nov 3, 2003, 11:10:55 AM11/3/03
to
Hi,
how can I use Serial Port in C#, using a framework native
code.
I dont want to use P/Invoke.

Tks,
Thiago

news.microsoft.com

unread,
Nov 3, 2003, 11:16:45 AM11/3/03
to
CraptiveX is the only way at present intil 2004 when we get System.IO.Ports
namespace

http://longhorn.msdn.microsoft.com

"Thiago Guedes" <thiago...@hotmail.com> wrote in message
news:002401c3a225$0f671790$a301...@phx.gbl...

Nicholas Paldino [.NET/C# MVP]

unread,
Nov 3, 2003, 11:17:08 AM11/3/03
to
Using an active X control still means that you will be using interop
code of some sort, and it will actually take more instructions to call the
COM code than it would to call the P/Invoke code.

Even when the System.IO.Ports namespace is introduced, my bet is that it
will just be a managed wrapper calling native code anyways, so you might
want to do this yourself for now, and switch over when the namespace is
introduced.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"news.microsoft.com" <discu...@discussion.microsoft.com> wrote in message
news:%23Uvu%23VioD...@TK2MSFTNGP09.phx.gbl...

Ed Sutton

unread,
Nov 3, 2003, 4:44:22 PM11/3/03
to
If you are going the MSComm COM interop route, simply add a reference in
your C# project to MSCommLib. Click on the COM
tab and browse to select your MSCOMM32.OCX .

Then create an instance of it in your C# class:

MSCommLib.MSComm mscomm = new MSCommLib.MSCommClass();

The MSComm control has been working fine for me however I am still looking
for a better .NET way to do it:

Some alternatives to using the MSComm control in .NET

C#
http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=b06e3
0f9-1301-4cc6-ac14-dfe325097c69

Managed C++
http://www.codeproject.com/managedcpp/howtocomport.asp

VB .NET
http://www.mentalis.org/classlib/class.php?id=15


http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=8aaa0
158-95b6-49a7-bb20-93391fc4c196

C# ( This uses thread pooling that is not supported under Win98)
http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=b06e3
0f9-1301-4cc6-ac14-dfe325097c69

C#
http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=fcba7
fc5-666e-4eb0-863f-0045b0c79ec7

-Ed


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.532 / Virus Database: 326 - Release Date: 10/27/2003


Alan Pretre

unread,
Nov 3, 2003, 6:38:55 PM11/3/03
to
"Nicholas Paldino [.NET/C# MVP]" <m...@spam.guard.caspershouse.com> wrote in
message news:Owe7uYio...@TK2MSFTNGP09.phx.gbl...

> Even when the System.IO.Ports namespace is introduced, my bet is that
it
> will just be a managed wrapper calling native code anyways, so you might
> want to do this yourself for now, and switch over when the namespace is
> introduced.

We use this MS source, haven't had any trouble with it. It looks a lot like
Longhorn, so I expect trivial conversion later.

http://www.gotdotnet.com/community/usersamples/Default.aspx?query=SerialPort

-- Alan


Ed Sutton

unread,
Nov 4, 2003, 10:30:24 AM11/4/03
to
> We use this MS source, haven't had any trouble with it. It looks a
> lot like Longhorn, so I expect trivial conversion later.
>
>
http://www.gotdotnet.com/community/usersamples/Default.aspx?query=SerialPort

The above approach does not support Win98 or WinME. It uses
BindIoCompletionCallback and Windows 95/98/Me are *all* not supported. Of
course .NET does not support Win95 at all.

Also, some methods of the ThreadPool Class are not supported by Win98.

-Ed


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).

Version: 6.0.532 / Virus Database: 326 - Release Date: 10/28/2003


0 new messages