473,788 Members | 2,897 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 15461
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
10166
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
1327
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
1822
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
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10370
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
10177
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...
1
10113
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5402
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
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2896
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.