473,800 Members | 2,385 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with System.IO.Ports .SerialPort.Ope n

Hi,
I've a strange problem with serial port class of .NET Framework 2.0
I use com0com (Null Modem COM Port emulator) to emulate a virtual
port.
This application creates virtual com port pairs with starting with
CNCA0 <-CNCB0
CNCA1<-CNCB1
etc.,
When I created a port with this name and try to open it using
SerialPort.Open ,
I get a ArgumentExcepti on stating "The given port name does not start
with COM/com or does not resolve to a valid serial port."
Where as if I create a virtual serial port pair by name
COM20<->COM21
I can open both the ports and send/receive data between them.
However, HyperTerminal works fine for both the COM Ports.

What could be the problem? Any Help would be appreciated.
How could I circumvent this error?

Regards,
Mugunth

Mar 7 '07 #1
3 15463
On Mar 7, 3:40 am, "Mugunth" <mugunth.ku...@ gmail.comwrote:
Hi,
I've a strange problem with serial port class of .NET Framework 2.0
I use com0com (Null Modem COM Port emulator) to emulate a virtual
port.
This application creates virtual com port pairs with starting with
CNCA0 <-CNCB0
CNCA1<-CNCB1
etc.,
When I created a port with this name and try to open it using
SerialPort.Open ,
I get a ArgumentExcepti on stating "The given port name does not start
with COM/com or does not resolve to a valid serial port."
Where as if I create a virtual serial port pair by name
COM20<->COM21
I can open both the ports and send/receive data between them.
However, HyperTerminal works fine for both the COM Ports.

What could be the problem? Any Help would be appreciated.
How could I circumvent this error?
It appears as if the SerialPort class requires that the port name
start with "COM". Here is part of the code that is in the
SerialPort.Open method:

if ((portName == null) || !portName.Start sWith("COM",
StringCompariso n.OrdinalIgnore Case))
{
throw new
ArgumentExcepti on(SR.GetString ("Arg_InvalidSe rialPort"), "portName") ;
}

Can you change the virtual port names used by the emulator?

Chris

Mar 7 '07 #2
On Mar 7, 7:31 pm, "Chris Dunaway" <dunaw...@gmail .comwrote:
On Mar 7, 3:40 am, "Mugunth" <mugunth.ku...@ gmail.comwrote:
Hi,
I've a strange problem with serial port class of .NET Framework 2.0
I use com0com (Null Modem COM Port emulator) to emulate a virtual
port.
This application creates virtual com port pairs with starting with
CNCA0 <-CNCB0
CNCA1<-CNCB1
etc.,
When I created a port with this name and try to open it using
SerialPort.Open ,
I get a ArgumentExcepti on stating "The given port name does not start
with COM/com or does not resolve to a valid serial port."
Where as if I create a virtual serial port pair by name
COM20<->COM21
I can open both the ports and send/receive data between them.
However, HyperTerminal works fine for both the COM Ports.
What could be the problem? Any Help would be appreciated.
How could I circumvent this error?

It appears as if the SerialPort class requires that the port name
start with "COM". Here is part of the code that is in the
SerialPort.Open method:

if ((portName == null) || !portName.Start sWith("COM",
StringCompariso n.OrdinalIgnore Case))
{
throw new
ArgumentExcepti on(SR.GetString ("Arg_InvalidSe rialPort"), "portName") ;
}

Can you change the virtual port names used by the emulator?

Chris
Yes,
It is possible to change the Virtual Serial Ports' name...
But my doubt is, why is it that this class alone mandates the name to
start with COM,
when the actual Windows API doesn't?

Regards,
Mugunth

Mar 8 '07 #3
On Mar 7, 10:01 pm, "Mugunth" <mugunth.ku...@ gmail.comwrote:
On Mar 7, 7:31 pm, "Chris Dunaway" <dunaw...@gmail .comwrote:
On Mar 7, 3:40 am, "Mugunth" <mugunth.ku...@ gmail.comwrote:
Hi,
I've a strange problem with serial port class of .NET Framework 2.0
I use com0com (Null Modem COM Port emulator) to emulate a virtual
port.
This application creates virtual com port pairs with starting with
CNCA0 <-CNCB0
CNCA1<-CNCB1
etc.,
When I created a port with this name and try to open it using
SerialPort.Open ,
I get a ArgumentExcepti on stating "The given port name does not start
with COM/com or does not resolve to a valid serial port."
Where as if I create a virtual serial port pair by name
COM20<->COM21
I can open both the ports and send/receive data between them.
However, HyperTerminal works fine for both the COM Ports.
What could be the problem? Any Help would be appreciated.
How could I circumvent this error?
It appears as if the SerialPort class requires that the port name
start with "COM". Here is part of the code that is in the
SerialPort.Open method:
if ((portName == null) || !portName.Start sWith("COM",
StringCompariso n.OrdinalIgnore Case))
{
throw new
ArgumentExcepti on(SR.GetString ("Arg_InvalidSe rialPort"), "portName") ;
}
Can you change the virtual port names used by the emulator?
Chris

Yes,
It is possible to change the Virtual Serial Ports' name...
But my doubt is, why is it that this class alone mandates the name to
start with COM,
when the actual Windows API doesn't?
I don't know why they chose to impose that restriction. Seems silly
to me as well.

Mar 8 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1441
by: Piotrekk | last post by:
Hi My question is: How to conrol output pins of ( for example ) COM1 I found in .net System.IO.Ports.SerialPort class. Is there any posibility to set or not set pins D0-7? Thanks PK
3
10171
by: SamB | last post by:
Hello all! MY CASE: I'm using VB.net 2005 express on a Dell Laptop with an USB Bluetooth key. I'm trying to send data to a pocketPC. COM numbers changes each time i've got a new bluetooh "connection" with my PDA. I need 2 ports, one for ingoing data, one for outgoing data (that's how serial port profile in bluetooth is made)
7
4941
by: Tamir.D | last post by:
is there a way to embed the System.IO.Ports.SerialPort object in my html . so that the client can access to a device connected to his SerialCOM ? i tried to wrap the System.IO.Ports.SerialPort in my own component and then put it in <object> but it doesnt seem to work, any suggestions?
0
1328
by: Suman | last post by:
Hi All, &nbsp; &nbsp;I am trying out a web based chat-server program on a server machine. I opened few PORTS during my trial runs and somehow the telnet session got crashed and I couldn't explicitly close the PORTs. Now when I try my program I get the following error http://152.69.155.107/chatserver2.php &lt;&lt;
0
385
by: ricolee99 | last post by:
Hi Everyone, I'm using the System.IO.Ports.SerialPort component to attempt to kill an existing component opened by another application. I use the following code: SerialPort serialPort = new SerialPort ("COM1"); if(serialPort.IsOpen)
4
8665
by: =?Utf-8?B?S3Jpc3RvZmZlciBQZXJzc29u?= | last post by:
Does anyone know if it's possible to get the Win32 handle to the serial port used under the hood in System.IO.SerialPort? The reason I want it is so I'd be able to make changes the DCB struct. I want to set the fRtsControl to RTS_CONTROL_TOGGLE so the RTS signal will be reset automatically when the TX buffer is empty. - Kristoffer -
0
1559
by: Bandu | last post by:
Hi, is System.IO.Ports.SerialPort supported in 64bit? I'm writing C# application and its worked fine with 32 bit. But in 64-bit, System.IO.Ports.SerialPort never fire up the Event Handler (e.g. PinChangedEvent ). Please, Help? Regards,
2
1823
by: Rof | last post by:
Can anyone tell me what is the best (not necessarily Microsoft's "preferred" way) of using serial ports, now that we at last have serial port objects in .NET? Should I use My.Computer.Ports.OpenSerialPort, as MS seem to recommend, or use the way that seems more intuitive and logical, Ports.SerialPort.Open? The first one is not very well explained - it seems to imply that if you do that with "COM1" as the port name, you then have an object...
1
1849
by: David Hearn | last post by:
(Apologies if this is not the appropriate group) I'm trying to use an external USRobotics USB modem (Model 5633B) in Vista - and talk to it via AT commands from my C# application (using VS2008 + .Net 2.0). Downloaded the Vista drivers, and it comes up as COM12. I also have a built-in modem in this laptop (COM3). I started off using CRT4 (old terminal app like Hyperterm) and can open and use both the modems, sending AT commands to...
0
10505
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10275
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10033
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7576
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5471
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.