views:

1692

answers:

3

Hello all

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 .

A: 

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

fupsduck
+5  A: 

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.

Aydsman
+1. In addition, if you are triggering a lot of exceptions and catching and ignoring them it might be worth trying to rewrite your code to avoid it as it'll perform much better. e.g use an if(thing != null) before the call instead of a catch(NullPointerException) afterwards.
Paolo
Definitely, Paolo. Exceptions should be exceptional. Of course if the exceptions are happening in Microsoft.VisualBasic.dll there are probably not too many things you can do, unfortunately. :)
Aydsman
Even if the exception is happening in Microsoft.VisualBasic.dll, it's most likely that it's being caused by an error in your own code, rather than a bug in the Microsoft code.
MarkJ
But How i can see where they come from in the code ?I just cant see the place it happens
Night Walker
Change the debugger setting so that it stops on first chance exceptions. Look back at the call stack to the last part of your code before it goes into the Microsoft DLL. Figure out what is wrong with your call into the Microsoft code. If everything is fine then just turn off the warnings, as in the linked question.
MarkJ
+4  A: 

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.

Marcus Andrén
+1 I have never noticed that before!!!
Christian Payne