Thursday, April 12, 2012

What things should I consider when I get an intermittent exception in Visual Basic .net (debugging in Visual Studio Express 2010)?

I'm testing my Visual Basic .net application by running it in Visual Studio express.



Sometimes it runs OK, but other times I get an exception (details below, if useful). I'm not sure why I get the exception as the particular part of the application that I am testing re-uses code that works OK for other features.



What should I check, what would give me a hint as to the root cause.



Things I tried so far are:




  • Rewriting some of the code to be more robust. The outcome of this was that this approach was getting out of control - I was correcting everything. I made changes such asing alternative libraries (e.g. replacing CInt with convertTo etc). Some lazy declarations, but it occurred to me that there was no problem with these with the code before my changes. And every change I seemed to solve uncovered yet another problem, another different exception

  • So I thought something must be fundamentally wrong with my installation, and a search found discussion group posts from people experiencing something similar. The suggested remedy would be to re-install the .net framework. So I did that and the problems still occured.



Any thoughts on approach to get to the root of the problem? I'm not asking for a solution but some fresh ideas would be very welcome.



Update:



I've added in the following code to get more detail (+1 thanks @Meta-Knight)



        Dim exceptionMessage As String = ex.Message
Console.WriteLine("Message: \n" & exceptionMessage)
Dim exceptionTargetSite As String = ex.TargetSite.ToString
Console.WriteLine("Inner: \n" & ex.TargetSite.ToString)
Dim exceptionSource As String = ex.Source
Console.WriteLine("Source\n:" & exceptionSource)
' put the stack trace into a variable
' (this helps debugging - put a break point after this is assigned
' to see the contents)
Dim stackTrace As String = ex.StackTrace.ToString()
Console.WriteLine("Stack trace\n:" & stackTrace)


More details about exception



Error - Exception Message
"Arithmetic operation resulted in an overflow."



Exception Target Site:
"Int32 ToInteger(System.String)"



Exception Source:
"Microsoft.VisualBasic"




at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value) at MyCo_3rd-Party-Industrial-Printing-System.Customer_EanUpc_serialNumberGeneratorAssembly.btnPrint_Click(Object sender, EventArgs e) in C:\labelprint\MyCo 3rd-Party-Industrial-Printing-System v2\MyCo 3rd-Party-Industrial-Printing-System\PrintForms\Customer_EanUpc_serialNumberGeneratorAssembly.vb:line 271 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.PerformClick() at System.Windows.Forms.Form.ProcessDialogKey(Keys keyData) at System.Windows.Forms.Control.ProcessDialogKey(Keys keyData) at System.Windows.Forms.Control.PreProcessMessage(Message& msg) at System.Windows.Forms.Control.PreProcessControlMessageInternal(Control target, Message& msg) at System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg) at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FPreTranslateMessage(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.RunDialog(Form form) at System.Windows.Forms.Form.ShowDialog(IWin32Window owner) at System.Windows.Forms.Form.ShowDialog() at MyCo_3rd-Party-Industrial-Printing-System.utlForm.openNewModalForm(String form) in C:\labelprint\MyCo 3rd-Party-Industrial-Printing-System v2\MyCo 3rd-Party-Industrial-Printing-System\Utilities\utlForm.vb:line 128






No comments:

Post a Comment