Ho fatto un'applicazione in VB2005 che DOVREBBE aprire la porta seriale e
iniziare a ricevere dati da una seriale, gestita tramite un controllo
SerialPort chiamato com0new. Però fallisce con un errore:
"UnauthorizedAccessException non è stata gestita. Accesso alla porta COM1
negato."
Questa è la funzione che genera quell'errore:
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)
'NON MI DA' L'AUTORIZZAZIONE
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
Mi è stato detto che per farla funzionare devo impostare i permessi, ma non
mi è stato detto come fare per impostarli. Qualcuno che lo sa, può per
favore dirmi come si fa?
Ringrazio in anticipo.