The Problem is simple, i am coding a tool which is able to connect GPS devices over the IO.Ports.SerialPort function in .NET
Everything works fine, but to list all available COM interfaces it looks like:
COM1
COM2%
COM3°
COM12$
开发者_开发知识库
its impossible to connect to a device which is called COM3°
. If i simply try to connect manually to COM3
it works perfect.
this is the code snippet which i am using right now:
For i As Integer = 0 To My.Computer.Ports.SerialPortNames.Count - 1
cbbCOMPorts.Items.Add(System.IO.Ports.SerialPort.GetPortNames(i))
Next
Thanks for your help ;)
I've seen this before, it's been a while. This is a bug in the driver, it is writing junk to the registry. Bobby gave you the location, have a look-see with Regedit.exe. Some kind of USB device, I imagine. Throw it away and find another from a different manufacturer. Cr*ppy drivers is not something you want to deal with.
Does the information at this Connect MSDN post help?
Specifically, I see this:
Thank you for reporting this issue. The root cause of this (RegistryKey.GetValue fails to properly handle non-null terminated string data) will be fixed for the next version of the .NET Framework.
Regards, Justin Van Patten
Edit: As noted in the comments above, this link and issue can be found in an existing Stackoverflow question.
This is another reason to use .Net 4.0 when using SerialPorts. Probably the biggest issue is to fix USB SerialPorts being removed when the port is open, which leads to many problems (yeah, I know that the user isn't supposed to...).
精彩评论