Problem when using SerialPort.GetPortNames  
Author Message
Will George





PostPosted: Installing and Registering Visual Studio Express Editions, Problem when using SerialPort.GetPortNames Top

General Information about my hardware/software.

Using a Acer Aspire 5670 laptop running XP Home (fresh install from mfg. software) with all the latest Microsoft service packs installed. Using Visual C# 2005 Express. Net Framework 1.1 and 2.0, Net Framework 2.0 SDK installed. I have uninstalled the Widcomm bluetooth stack (from laptop mfg.) and now using the Microsoft bluetooth stack.

In general my laptop seems to be working OK. In other words, no problems at the moment (Knock on wood)

Now my question/problem..
When using SerialPort.GetPortNames the string[ ] containing each Com port name/number is returned corrupt.

//My tests for list of serial port names.
//Using all of the following returns the same corrupt string during debug

//ports,x, and portsnew will all be the same strings

string[] ports;
ports = SerialPort.GetPortNames();
string[] x = null;
x = SerialPort.GetPortNames();
string[] portsnew = SerialPort.GetPortNames();

The strings returned have one extra character at the end of the Com port names. This character appears to be random (sometimes even looks like some oriental character). Anyway, during a debug I checked the string used and it is null before use. Note that all ports returned will have the extra character. As far as I can recall all the names (be it one port or several have the same character).

It appears to be something with the registry but I have no idea how to correct my problem. If I use regedit and check HKEY, Local Machine, Hardware, Devicemap, SerialComm the REG_SZ strings for each port appear to be normal (no extra characters visable). If I double click the REG_SZ and view the dialog (no changes made to the string) and re-run my program the strings are returned without error. In fact I can type any string into the REG_SZ and it is returned by GetPortNames as I typed it (Just short strings).

If the registry changes due to port changes or I restart the laptop, the strings returned are again corrupt.

My various bluetooth adapters, Palm, and NXT brick will sometimes cause the port numbers to change depending on what I'm doing at the time.

NO I DO NOT want to reload all my software AGAIN! and I really do not want to do any restore to earlier date unless I have to.


Thanks in advance for any advice.
Ya all have a GREAT day!




Visual Studio Express Editions23  
 
 
nobugz





PostPosted: Installing and Registering Visual Studio Express Editions, Problem when using SerialPort.GetPortNames Top

Though problem. SerialPort.GetPortNames() is a very thin, it simply enumerates the values in HKLM\Hardware\DeviceMap\SerialComm. You might possibly not see the extraneous character in RegEdit because it doesn't display the stray Unicode character. Perhaps your standard serial port driver was replaced by a buggy vendor version. Control panel + System, Hardware tab, Device Manager button, Ports, COMx. Right click and check the Drivers tab. Mine is Microsoft, 7/1/2001, V5.1.2600.0


 
 
jo0ls





PostPosted: Installing and Registering Visual Studio Express Editions, Problem when using SerialPort.GetPortNames Top

I get this too, on three computers with xp sp2, same dongle. The driver details are:

Standard Serial Over Bluetooth Link <- not the standard com port driver!!

Driver Provider: Microsoft
Driver Date: 03/08/2004
Driver Version: 5.1.2600.2180
Digital Signer: Microsoft Windows Publisher.

The first com port it finds is ok, the rest have a variable additional character.
Regex to the rescue...

ah, it's a reported bug...
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx FeedbackID=236183

Stranger still, it seems to be ok if you build a release rather than debug.