Ports
May 21, 2013, 05:08:46 pm
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
: SMF - Just Installed!
Home
Help
Search
Login
Register
Welcome to the PORTS Forum. Please post your questions, answers, and comments relating to USB and other hardware interfaces in the appropriate forums below. - Jan
Ports
>
General Category
>
USB
>
WriteFile causes exception in VB.net but not VC++
Pages: [
1
]
« previous
next »
Print
Author
Topic: WriteFile causes exception in VB.net but not VC++ (Read 2344 times)
theoracle39
Member
Posts: 8
WriteFile causes exception in VB.net but not VC++
«
on:
July 09, 2010, 04:12:29 pm »
If I detect a USB device, unplug it, and then try to write to the device WriteFile causes an exception in VB.net. If I run the same code in VC++ it returns WriteFile as false as it should. Why does the function work differently in one language than the other? How do I get WriteFile to return as false in VB.net if a USB device is suddently unplugged?
Logged
Jan Axelson
Administrator
Frequent Contributor
Posts: 1627
Re: WriteFile causes exception in VB.net but not VC++
«
Reply #1 on:
July 09, 2010, 07:39:50 pm »
The exception is giving you useful information - you can no longer communicate with the device because it's no longer attached or other communication problems. If you don't need the information, catch and otherwise ignore the exception.
Jan
Logged
theoracle39
Member
Posts: 8
Re: WriteFile causes exception in VB.net but not VC++
«
Reply #2 on:
July 10, 2010, 07:41:06 am »
If I ignore the exception then the program crashes with the message ObjectDisposedException was unhandled by user code. I think this exception either needs to be prevented from happening or I need to be able to deal with it once it happens. Any suggestions?
Logged
Jan Axelson
Administrator
Frequent Contributor
Posts: 1627
Re: WriteFile causes exception in VB.net but not VC++
«
Reply #3 on:
July 10, 2010, 10:59:09 am »
By ignore I meant catch the exception but take no action in the exception handler.
Jan
Logged
Pages: [
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General Category
-----------------------------
=> USB
=> Serial Ports
=> Embedded Ethernet
=> Parallel Port
=> Other Interfaces
=> General Discussion
Loading...