The "Catch" on its own did not work.
I have changed it to be this and i still get the error.
====
Debug.WriteLine("b4exp")
Try
ListeningSerialPort.Close()
Catch extry As System.UnauthorizedAccessException
Debug.WriteLine("cought it")
Catch ex As Exception
Debug.WriteLine("other caught it")
End Try
Debug.WriteLine("aftb4exp")
===
my output is as follows in the immedate window
b4exp
A first chance exception of type 'System.UnauthorizedAccessException'
occurred in System.dll
cought it
aftb4exp
====
I cant seem to get around it from it throwing that exception. Any other
ideas?
What I am basically doing is i have a proximety scanner hooked up thru a usb
to my computer.
In the begining what I do is
if serial.isopen() = false then serial.open()
then what I do is i unplug the usb.
The problem is that when I unplug the usb isopen still returns True, so
what I do is I have a timer and every so many seconds and i then
Dim CurrentAvailPorts As Array = SerialPort.GetPortNames()
and compare what port names are available to the ones I THINK that are open,
and if they are actaully not anymore ( by GetPortNames() ) I try to close
them. Thats where the error is occuring.
That way, every so many seconds...when GetPortNames does return my ComPort
that was opened and is available again - I re-open it.
The Part that is failing is the "closing" of the port when the usb is
unplugged.
Any other Ideas?
Thanks
Miro
"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11**********************@l70g2000hse.googlegr oups.com...
On Aug 1, 12:03 pm, "Miro" <miron...@golden.netwrote:
>I cant seem to find an example on how to do something, ( vb2005.express )
i have a
Try
ListeningSerialPort.Open()
TestText.Enabled = True
Catch ex As Exception
'Debug.WriteLine(ex.Message)
End Try
<morecodehere>...
statement, and what I am tryign to do is Catch the exception ( which it
does ) but i dont want to throw it anywhere.
How do I get this try catch to continue gracefully so if an exception is
caught, the "more code here" gets executed and continues on - the user
never
sees that an exception was hit and they do not know the difference?
Currently when I compile / and create a setup.exe with the publish and
install it, the program hits a fatal exception -displays it to the user
and
fails. If I run the same program in vb.net express, then this does not
happen, it shows the exception in the immediate window but lets me
continue.
Am I missing something with the Try Catch statement ?
I hope that makes sence.
Miro
Your current try catch should "continue gracefully" on any Exception
object - so I'm not sure why it isn't. You might try omitting the "ex
as exception" part - this will cause it to trap all but a few really
nasty (and normally non-recoverable) exceptions.
i.e.
Try
...
Catch
...
End Try
Also, are you sure the exception is from this method? Perhaps you are
hitting a security exception or something before you make it to the
above code?
Thanks,
Seth Rowe