Click here to Skip to main content
15,905,008 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionSerialPort throwing uncatchable error? Pin
Chinners15-Apr-08 1:18
Chinners15-Apr-08 1:18 
Hi,

I am having a bit of difficulty trying to catch an error thrown by io.ports

I have an app that displays a message on an external screen, using serial comms. The routine to do this needs to be as "bullet-proof" as possible.

Testing the code, it is fine on a standard serial port, I can unplug the port and plug it back in again, and the code recovers, but as an ultimate "real world" test, I tried it on a USB->Serial adapter, and it works well - untill I unplug the USB cable and plug it back in again.

Now, what happens is a bit strange. The application recovers (so the com port is coming back), and starts displaying messages again, but only for a few seconds. I then get the following exception:

System.UnauthorizedAccessException was unhandled
  Message="Access to the port is denied."
  Source="System"
  StackTrace:
       at System.IO.Ports.InternalResources.WinIOError(Int32 errorCode, String str)
       at System.IO.Ports.SerialStream.Dispose(Boolean disposing)
       at System.IO.Ports.SerialStream.Finalize()


I cannot trap this error, and the application just bombs out. I certainly am not disposing of the serialport object I have created, so this must be being done automatically.

But, my question is, how do I catch, and trap this error? Any help, or pointers would be much appreciated.

Thanks,

Jason
GeneralRe: SerialPort throwing uncatchable error? Pin
Dave Kreskowiak15-Apr-08 1:40
mveDave Kreskowiak15-Apr-08 1:40 
GeneralRe: SerialPort throwing uncatchable error? Pin
Chinners15-Apr-08 1:48
Chinners15-Apr-08 1:48 
GeneralRe: SerialPort throwing uncatchable error? Pin
Rajesh Anuhya15-Apr-08 1:43
professionalRajesh Anuhya15-Apr-08 1:43 
GeneralRe: SerialPort throwing uncatchable error? Pin
Chinners15-Apr-08 1:59
Chinners15-Apr-08 1:59 
QuestionVB6 User mode code memory limitation Pin
Hafiz Sikander Rafiq15-Apr-08 0:29
Hafiz Sikander Rafiq15-Apr-08 0:29 
GeneralRe: VB6 User mode code memory limitation Pin
Christian Graus15-Apr-08 0:59
protectorChristian Graus15-Apr-08 0:59 
GeneralRe: VB6 User mode code memory limitation Pin
Dave Kreskowiak15-Apr-08 1:38
mveDave Kreskowiak15-Apr-08 1:38 
QuestionHow to add VFP Driver Pin
en.Mahdi14-Apr-08 23:38
en.Mahdi14-Apr-08 23:38 
GeneralRe: How to add VFP Driver Pin
Christian Graus15-Apr-08 0:03
protectorChristian Graus15-Apr-08 0:03 
Questionhow i can prohibt a user to delete a row from a table when it exist in another table ? Pin
r_mohd14-Apr-08 22:19
r_mohd14-Apr-08 22:19 
GeneralRe: how i can prohibt a user to delete a row from a table when it exist in another table ? Pin
Christian Graus15-Apr-08 0:05
protectorChristian Graus15-Apr-08 0:05 
GeneralRe: how i can prohibt a user to delete a row from a table when it exist in another table ? Pin
Ashish Sehajpal15-Apr-08 4:28
Ashish Sehajpal15-Apr-08 4:28 
GeneralRe: how i can prohibt a user to delete a row from a table when it exist in another table ? Pin
Dave Kreskowiak15-Apr-08 4:42
mveDave Kreskowiak15-Apr-08 4:42 
GeneralRe: how i can prohibt a user to delete a row from a table when it exist in another table ? Pin
Steven J Jowett15-Apr-08 5:59
Steven J Jowett15-Apr-08 5:59 
GeneralRe: how i can prohibt a user to delete a row from a table when it exist in another table ? Pin
Dave Kreskowiak15-Apr-08 6:26
mveDave Kreskowiak15-Apr-08 6:26 
GeneralRe: how i can prohibt a user to delete a row from a table when it exist in another table ? Pin
Christian Graus16-Apr-08 11:15
protectorChristian Graus16-Apr-08 11:15 
Questionregarding message box in vb.net Pin
vijaylumar14-Apr-08 19:02
vijaylumar14-Apr-08 19:02 
AnswerRe: regarding message box in vb.net Pin
en.Mahdi14-Apr-08 19:33
en.Mahdi14-Apr-08 19:33 
GeneralRe: regarding message box in vb.net Pin
Christian Graus14-Apr-08 19:39
protectorChristian Graus14-Apr-08 19:39 
QuestionHow to add VFP driver Pin
en.Mahdi14-Apr-08 11:04
en.Mahdi14-Apr-08 11:04 
Questionform withe tabs Pin
asha_s14-Apr-08 9:46
asha_s14-Apr-08 9:46 
GeneralRe: form withe tabs Pin
Christian Graus14-Apr-08 11:18
protectorChristian Graus14-Apr-08 11:18 
GeneralRe: form withe tabs Pin
asha_s15-Apr-08 0:50
asha_s15-Apr-08 0:50 
GeneralRe: form withe tabs Pin
Smithers-Jones14-Apr-08 11:20
Smithers-Jones14-Apr-08 11:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.