#Visual basic net try catch code#
The combo code tries to access the current datatable row and it dies a horrible death. We are deleting a row from a datatable which triggers a position change in our bindingsource object which, in turn, triggers a text changed event in a combo control. The call stack shows a number of managednative transitions and it appears that is causing the exceptions to be swallowed. We have code that is throwing an error in VS but when we enclose the line of code that initiates the error in a try/catch, nothing is caught. ĭavid, We have a reproducible issue that sounds similar but not exact. This entry was posted in Programming, Visual Basic. A kludge definitely, but expecting MS to fix an obscure bug like this is unlikely – after all, like Bigfoot, no one believes you when you say you’ve seen it in the wild… When the data stops, the program is considered dead/hung, and is killed and restarted. In my case, I’m now (somewhat) content to know it exists and is beyond the ability of this mortal VB programmer to fix – so I’ll try to bypass the dll code, and if necessary, set up a deadman program, a hidden program that monitors the first, such as by getting data piped to it regularly. So of course it’s a great bug – programmers don’t encounter it in their debug testing, but the release version shows it up real nice! As well, it is a fine example of a Heisenbug, and changes as you test for it either under debug or release code – in fast, I had to compile my test C++ dll AND Visual Basic program under Release to get it to consistently blow up.
#Visual basic net try catch windows#
Reproducible implies fixable – or at least an end to wasted time saying “it doesn’t exist” and more time spent on trying to solve it.īut can it be fixed? I’m thinking not, but I’d be very happy to be proven wrong – the problem seems to be that sometimes specific parts of the stack are overwritten by an errant pointer, triggering the big bad Windows to crush the program in what is known as a Corrupted State Exception, or CSE.
![visual basic net try catch visual basic net try catch](https://images.slideplayer.com/16/4997784/slides/slide_3.jpg)
Now in all fairness, I was one of those people – I firmly believed that the problem could not exist, and if it did, somehow it could be tamed by an exotic exception handler or some other code – so I’m both annoyed and delighted to point to a real example of the bug in the wild that is consistently bad – and that’s good. And in case there’s any doubt, I tried both C++ try/catch and Structured Exception Handling (SEH) with _try/_except.Īt about this point, most threads stop – having exhausted all the standard guesses, people quit offering help. First off, it doesn’t work (I tried) and second, not all of us have access to the dll’s source. Of course, forum threads would suggest these things, and when they didn’t work, they went on to suggest programming the dll to include C++ try/catch code. net 1.0/1.1 handling could solve it (it didn’t).
![visual basic net try catch visual basic net try catch](https://i.ytimg.com/vi/lkGLQvl9Vls/hqdefault.jpg)
net 4.0 or later – since I was in 2.0, it was a waste of time. But of course, that’s only needed when moving to. The gist of it is he used a C++ dll called by VB, and the dll executed this bit of code, which created an empty vector, then tried to display element 1 anyways: #include The second thing I found out was an obscure post – someone who not only had the problem, but could reproduce it – with code attached. The most belligerent replies (including one that said “it can’t happen” which I felt was rather omnipresent of him) had impressive MS credentials listed. Many posts starting with “I have an exception I can’t catch” ended unresolved and abruptly. I was about to add Application.ThreadException and handlers when it happened…Īnd despite the bulletproofing, it wasn’t caught, and the program didn’t fail gracefully – it aborted.įirst thing I found out – a lot of MS professionals believe every exception can be caught with the right code (with the ‘exception’ of Environment.FailFast of course, which is after all deliberately designed to bypass try/catch/finally code and finalizers).
![visual basic net try catch visual basic net try catch](https://www.loggly.com/wp-content/uploads/2016/11/NET-Logging-Basics-06-1.png)
Even with some sweet error logging and program restart code I added, it still blew skyhigh (apparently). Then I tried top level protection with MyApplication_UnhandledException in my ApplicationEvents.vb file (to get that, click on ‘View Application Events’ in the program’s Properties Application tab).Obviously, I already had try/catch code around everything – and sometimes it was caught.So I searched the Internet, and dutifully bolstered my source code as advised: As you can imagine, I couldn’t reproduce the bug – always a good sign that the solution will be dead simple. net program, and they’ve been reporting exceptions that abruptly close the program (or else provide the ‘send an error report to Microsoft’ dialog, which is just as serious). I’ve been troubleshooting a client’s Visual Basic. Forget the $10,000,000 hunt for Bigfoot – here’s a very different search for an imaginary beastie that did pay off.