From: EYSRG on
I made a VB2005 app which is *supposed* to open the serial port and receive
data from it (the serial port is controlled by a SerialPort control named
com0new). However, it fails with an exception:

"UnauthorizedAccessException
Access to the port 'COM1' is denied."

COM1 is the only serial port my computer has, and I know it is unused when I
run the program.
The following is the function generating the exception:

Function ReceiveSerialData() As String
' Receive strings from a serial port.
Dim returnStr As String = ""

Using com0new As IO.Ports.SerialPort = _
My.Computer.Ports.OpenSerialPort(frmMain.com0new.PortName) 'IT
WILL NOT AUTHORIZE ME
Do
Dim Incoming As String = com0new.ReadLine()
If Incoming Is Nothing Then
Exit Do
Else
returnStr &= Incoming & vbCrLf
End If
Loop
com0new.Close()
End Using

Return returnStr
End Function

I was told I need to set permissions to make it work; unfortunately, the
person who told me this does not know how to set permissions. I'm new to
VB2005, and sometimes I still think in terms of VB6: can you please tell me
how to solve the problem?

I thank you in advance.


From: Jan Hyde on
"EYSRG" <nientespam(a)no.no>'s wild thoughts were released on
Tue, 5 Dec 2006 10:13:51 +0100 bearing the following fruit:

>I made a VB2005 app which is *supposed* to open the serial port and receive

look for groups with 'dotnet' in the name, this is a VB6
(and below) group.

J


>data from it (the serial port is controlled by a SerialPort control named
>com0new). However, it fails with an exception:
>
>"UnauthorizedAccessException
>Access to the port 'COM1' is denied."
>
>COM1 is the only serial port my computer has, and I know it is unused when I
>run the program.
>The following is the function generating the exception:
>
>Function ReceiveSerialData() As String
> ' Receive strings from a serial port.
> Dim returnStr As String = ""
>
> Using com0new As IO.Ports.SerialPort = _
> My.Computer.Ports.OpenSerialPort(frmMain.com0new.PortName) 'IT
>WILL NOT AUTHORIZE ME
> Do
> Dim Incoming As String = com0new.ReadLine()
> If Incoming Is Nothing Then
> Exit Do
> Else
> returnStr &= Incoming & vbCrLf
> End If
> Loop
> com0new.Close()
> End Using
>
> Return returnStr
> End Function
>
>I was told I need to set permissions to make it work; unfortunately, the
>person who told me this does not know how to set permissions. I'm new to
>VB2005, and sometimes I still think in terms of VB6: can you please tell me
>how to solve the problem?
>
>I thank you in advance.
>


Jan Hyde (VB MVP)

--
In today's economy, we're all looking for a profit to lead us out of the wilderness. (Jenni Saqua)