A first chance exception - vb.net

I have a project that runs perfect under windows xp.
Now I have tried to run it under Windows 7 and got there a lot of exceptions under Immediate window.
A first chance exception of type 'System.ArgumentNullException' occurred in Microsoft.VisualBasic.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in LP_Wizard.exe
A first chance exception of type 'System.ArgumentException' occurred in LP_Wizard.exe
A first chance exception of type 'System.NullReferenceException' occurred in LP_Wizard.exe
A first chance exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
A first chance exception of type 'System.ArgumentNullException' occurred in Microsoft.VisualBasic.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in LP_Wizard.exe
A first chance exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
A first chance exception of type 'System.ArgumentNullException' occurred in Microsoft.VisualBasic.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in LP_Wizard.exe
A first chance exception of type 'System.ArgumentNullException' occurred in Microsoft.VisualBasic.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in LP_Wizard.exe
Any idea what wrong with that Microsoft.VisualBasic.dll in windows 7 and how i correct that problem ?
Thanks a lot for help .

If you want to pinpoint where the exceptions are occurring, you can select the Debug->Exceptions menu item, and in the dialog that appears, check the first checkbox for "Common Language Runtime Exceptions". This will make the debugger break as soon as an exception occurs instead of only breaking on unhandled exceptions.
This is also one reason why it is generally a bad idea to catch generic exceptions unless you are clearly logging the information caught.

What is happening is the debugger can "see" exceptions as soon as they are raised (hence the "first chance") before any catch block is hit. Any exception which is not handled by a catch block is considered a "second chance" exception and will break normally.
If these exceptions aren't stopping the running of your application because they are unhandled then you are probably OK. Most of the time the exception is handled by code and this isn't a problem. The output is simply Visual Studio letting you know the exceptions were raised.
See the "Avoiding first chance exception messages when the exception is safely handled" question for some methods to reduce this if there are too many to ignore.

Are your in the debugger? Are these exceptions your program is handling? If so you need to find a setting that tells VB to supress warning you of handled exceptions. Maybey this was set when installed on XP but not when you installed on W7. See if this helps:
http://www.helixoft.com/blog/archives/24

Related

Exception access violation (msvcrt.dll)

I received silent crashes, and in order to find their reasons, I collected a crash dump. When I try to debug it, I get the error
Exception thrown at 0x748E89EA (msvcrt.dll) in app.exe.10228.dmp:
0xC0000005: Access violation reading location 0x0457351A.
I can’t find out exactly where this error occurs, because it occurs spontaneously during working.
After all, in vb.net there is no direct memory access, where could this error be? Is it possible that it is from the dll files that the program uses?
Call stack of thread in which appeared exception:
ntdll!NtWaitForMultipleObjects+c
KERNELBASE!WaitForMultipleObjectsEx+133
KERNELBASE!WaitForMultipleObjects+18
kernel32!WerpReportFaultInternal+3b7 kernel32!WerpReportFault+9d
kernel32!BasepReportFault+19 KERNELBASE!UnhandledExceptionFilter+2a2
ntdll!__RtlUserThreadStart+3a4e6 ntdll!_RtlUserThreadStart+1b

Selenium: Does it useful to catch NoSuchElementException appears for a clickable element?

Why do we catch NoSuchElementException? It makes sense to catch the exception when we only verify the presence of an element in a particular page and not performing any actions on it. We can catch this exception and log a custom message like "Element not found"
When we are about to click an element and if it is not found in the page, selenium throws NoSuchElementException. What is the use of catching this exception instead of letting it to halt the test and failing the testcase?
Note: My subsequent steps depends on this clicking step.
One reason to catch the exception is to provide more relevant test failure output. For example, if a div element isn't found in a page of 20-30 divs, cause the selector doesn't match that specific div, you could let the exception remain uncaught with a generic error message or you could catch it and throw a different exception with error message "navbar is missing".
If it is clear from the generic error message what is wrong, or you have a test failure message that explains it, there is no reason to catch it.
A different reason to catch this exception is that it's part of skip code (skip this test if/unless). So you look for an element and if it's present you proceed with the test, if it's not - you skip it.
There may be other reasons, but these are two common ones.
There are two types of Exceptions:
1.Checked Exceptions
2.Unchecked Exceptions
Checked Exceptions are checked at compile time only, these should be handled by the programmer. Compiler will check at compile time whether these exceptions are handled or not if not compile time error occurs. Some of the checked exceptions are IOException, FileNotFoundExpection,etc.
Unchecked Exceptions:
Unchecked exceptions are not checked by compiler at the time of compilation. the exceptions which are extended by RuntimeException class are all unchecked exceptions. Some of the unchecked exceptions are AritmeticException, NullPointerException etc. In selenium we see unchecked exceptions such as NoSuchElementException, StaleElementReferenceException , NoSuchWindowException, TimeoutException etc.
In short, Checked exceptions must be caught. RuntimeException, also called unchecked exceptions, should not be caught
More info can be found on
http://toolsqa.com/selenium-webdriver/exception-handling-selenium-webdriver/
http://www.seleniumeasy.com/java-tutorials/exception-handling-in-selenium-webdriver-using-java-examples

Azure Service Bus thrown exceptions cluttering debug output

I'm running Azure Service Bus as a transport with NServiceBus. In my Visual Studio Output window, I am getting tons of exceptions thrown. They don't appear to actually be causing any issues with the system, everything works fine. They fire off every 25-30 seconds, so as you can imagine, this really clutters my output log and makes it difficult to read.
This is a sample of what gets printed every 30 seconds or so. This is only a small section of the total lines, roughly about 50-70 lines of FaultException and TimeoutExceptions in no particular order :
Exception thrown: 'System.ServiceModel.FaultException'1' in Microsoft.ServiceBus.dll
Exception thrown: 'System.ServiceModel.FaultException1' in Microsoft.ServiceBus.dll
Exception thrown: 'System.ServiceModel.FaultException1' in Microsoft.ServiceBus.dll
Exception thrown: 'System.ServiceModel.FaultException1' in Microsoft.ServiceBus.dll
Exception thrown: 'System.ServiceModel.FaultException1' in Microsoft.ServiceBus.dll
Exception thrown: 'System.TimeoutException' in Microsoft.ServiceBus.dll
I was able to resolve this by checking "Enable Just My Code" in Tools -> Options -> Debugging -> General.

COM Exception silently eaten

I have a native exe loading managed code that calls a COM object. The managed code attempts to set up a call back using IConnectionPoint. However the Advise method on the COM side returns E_FAIL. A manged COMException is thrown but my code does not catch the exception and I am not sure where it is handled. In fact I am modifying the COM code to set up a status flag to indicate connection status... a kludge I could avoid if the COMException could only be caught. I can see the COM exception in Windbg but the stack trace on the exception is empty. Any suggestion as to how to find out where the exception is being swallowed.

How to debug exception on other thread?

I have a lot of shortlived threads that updates my program, by events fired from a socket connection. My problem is I don't know how to debug this, like how to get the proper information on where in the code the exceptions occur. Because I get for example an exception like below, and this will just be the print in the Immidiate Window. There is no pop-up window, and it does not highlight any line in the code or show even what method it was in.
What am I missing? What I can do to see these things? And what improvements does VS2010 give on this situation, if any?
A first chance exception of type 'System.InvalidOperationException' occurred in System.Core.dll
A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll
A first chance exception of type 'System.Threading.ThreadAbortException' occurred in Krs.Ats.IBNet.dll
Go to "Debug -> Exceptions...", locate the "Common Language Runtime Exceptions" and check the "Thrown" mark. Now start debugging your application. Once any of CLR exception occurs the execution will stop on that line.