2
votes

I am getting a different stack trace in VS2013 when I do "DEBUG -> Start Debugging" and "DEBUG -> Start Without Debugging". It seems like the outer exception is getting dropped.

Here's what I get when I do "DEBUG -> Start Debugging" (notice the outer exception):

EmgNet.Exceptions.SQLExecutionException: Incorrect syntax near 'Heights_xlsx'.
Failed while executing: 'IF OBJECT_ID('tempdb..#mapping_Heights_xlsx') IS NOT NULL DROP TABLE #mapping_Heights_xlsx' ---> System.Data.SqlClient.SqlException: Incorrect syntax near 'Heights_xlsx'.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlCommand.EndExecuteNonQuery(IAsyncResult asyncResult)
   at EmgNet.DataLib.ExecSql(String SqlText, IDbConnection& Connection, Int32 CommandTimeout, IDbTransaction& Transaction, String MultipleRowSeparator, Object FieldNames, SqlExecType ExecType) in C:\DevHome\TFS\Projects\DataLib.vb:line 4181
   --- End of inner exception stack trace ---
   at EmgNet.DataLib.ExecSql(String SqlText, IDbConnection& Connection, Int32 CommandTimeout, IDbTransaction& Transaction, String MultipleRowSeparator, Object FieldNames, SqlExecType ExecType) in C:\DevHome\TFS\Projects\DataLib.vb:line 4207
   at EmgNet.DataHandler.ExecSql(String SqlText, IDbConnection& Connection, Int32 CommandTimeout, IDbTransaction& Transaction, String MultipleRowSeparator, Object FieldNames, SqlExecType ExecType) in C:\DevHome\TFS\Projects\DataHandler.vb:line 1248
   at EmgNetExt.SimpleFileImporterMapper.LoadFileInternal(String file) in C:\DevHome\TFS\Projects\DataLoaderWithMapper\SimpleFileImporterMapper.vb:line 36
   at EmgNetExt.AFileImporterMapper.LoadFile(String file) in C:\DevHome\TFS\Projects\DataLoaderWithMapper\AFileImporterMapper.vb:line 19
   at EmgNetExt.frmDataLoaderWithMapper.LoadFile() in C:\DevHome\TFS\Projects\DataLoaderWithMapper\frmDataLoaderWithMapper.vb:line 130
   at EmgNetExt.frmDataLoaderWithMapper.frmDynamicDataLoader_Shown(Object sender, EventArgs e) in C:\DevHome\TFS\Projects\DataLoaderWithMapper\frmDataLoaderWithMapper.vb:line 55
   at System.Windows.Forms.Form.OnShown(EventArgs e)
   at System.Windows.Forms.Form.CallShownEvent()
   at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
   at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
   at System.Threading.ExecutionContext.runTryCode(Object userData)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
   at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 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 frmStart.NewImportToolStripMenuItem_Click(Object sender, EventArgs e) in C:\DevHome\TFS\Projects\frmStart.vb:line 3358
   at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
   at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 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.Run(ApplicationContext context)
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
   at My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Here's what I get when I do "DEBUG -> Start Without Debugging" (notice the absence of outer exception):

System.Data.SqlClient.SqlException: Incorrect syntax near 'Heights_xlsx'.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlCommand.EndExecuteNonQuery(IAsyncResult asyncResult)
   at DataLib.ExecSql(String SqlText, IDbConnection& Connection, Int32 CommandTimeout, IDbTransaction& Transaction, String MultipleRowSeparator, Object FieldNames, SqlExecType ExecType) in C:\DevHome\TFS\Projects\DataLib.vb:line 4181

I am stumped on why this could be happening. Why would the stack trace change when running with the debugger or running without the debugger?

1
Is it reasonable to assume that it's the same exception being presented in two different ways? - Cameron
Maybe running without the debugger is not including all the debug information. Does running without debugging run the Release version? And if so, does your release configuration include the creation of .pdf file? Also, there could be optimizations going on that causes the compile code to be slightly different. - Chris Dunaway
@ChrisDunaway, selecting "Start Without Debugging" does not necessarily run the Release version (unless you specifically have the "Release" configuration chosen). See this link for the distinction between starting with or without debugging. - hunch_hunch

1 Answers

0
votes

In visual studio if you go to the menu Debug -> Exceptions you'll see a form with exceptions like common language runtime exceptions, Managed Debugging Assistants, and so on. Depending on this setup is usually where the differences between the stack traces are from as with Visual Studio it may break earlier or it may not break at all and will just continue trying to run. If you want more detail than that, then hopefully someone else can answer. I just know that this is usually the reason why stack traces are different.