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?