Debugging a crash - vb.net

I am normally pretty good about debugging errors based on the exception message, but this one has me stumped. Can someone take a look and give me some advise? The application works on 9 out of 10 computers. 1 computer I have loaded it on gives this error, all other work fine. Systems are the same to my knowledge.
Application crashes when clicking the 'GO' button, when doing that, it attaches itself to Outlook and sends an email.
Error:
> ************** Exception Text **************
System.Runtime.InteropServices.COMException (0x80080005): Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
at System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(RuntimeType objectType)
at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(RuntimeType serverType)
at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, Boolean bNewObj)
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at SickPrinter.Form1.Go_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Thanks in advance

Related

.NET 3.5 Migration to 4.5 issue with CrystalReports

I'm migrating an old .NET Framework 3.5 WinForm project to .NET Framework 4.5.2 and then it will be migrated to 4.8 but i have yet some problems with CrystalReports used in that project.
In:
Dim rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
vedirpt = New CrystalDecisions.Windows.Forms.CrystalReportViewer
rpt.PrintOptions.PrinterName = DammiPRNPDF()
rpt.Load("C:\Project\RPT\VEN_ARTORA.rpt")
rpt.SetDataSource(datsRPT)
I get an exception at like SetDataSource after the migration with the following stacktrace:
CrystalDecisions.CrystalReports.Engine.DataSourceException
HResult=0x80041700
Message=Unknown Query Engine Error
Error in File C:\Users\imytyuk\AppData\Local\Temp\VEN_RC {B1FC7324-0B9F-4E02-A31B-278FD0C30640}.rpt:
Unknown Query Engine Error
Source=CrystalDecisions.ReportAppServer.DataSetConversion
StackTrace:
at CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception e)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSourceInternal(Object val, Type type)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDataSource(DataSet dataSet)
at Project.frmSTATVEL.VediVENRC(Int32 Dal, Int32 Al, String DaDATA, String ADATA, String Excel, String GRUPPO) in E:\VisualStudio\Visual Studio 2019\Project\Project\frmSTATVEL.vb:line 5501
at Project.frmPRNREP.cmdPRNSCO_Click(Object sender, EventArgs e) in E:\VisualStudio\Visual Studio 2019\Project\Project\frmPRNREP.vb:line 90
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.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(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 Project.frmSTATVEL.cmdREPORT_Click(Object sender, EventArgs e) in E:\VisualStudio\Visual Studio 2019\Project\Project\frmSTATVEL.vb:line 13125
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.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(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 Project.frmCASSA.cmdRPT_Click(Object sender, EventArgs e) in E:\VisualStudio\Visual Studio 2019\Project\Project\frmCASSA.vb:line 41283
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.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(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 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at Project.My.MyApplication.Main(String[] Args) in :line 83
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
COMException: Unknown Query Engine Error
Error in File C:\Users\imytyuk\AppData\Local\Temp\VEN_RC {B1FC7324-0B9F-4E02-A31B-278FD0C30640}.rpt:
Unknown Query Engine Error
What can be done without changing the CR version? the projects uses CRRedis 2008
To make the older version of CrystalReport works on .NET Framework 4.5.2 and above i had to add the useLegacyV2RuntimeActivationPolicy set to true in app.config file.
So the line from this:
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /></startup>
Become this:
<startup useLegacyV2RuntimeActivationPolicy="true"><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /></startup>

VB.NET throws System.IO.IOException unsupported when trying to overwrite file

I have this code in my application:
My.Computer.FileSystem.CopyFile("D:\Temp\Origin.log", "D:\Temp\Destination.log", True)
This code used to work fine until 1 or 2 months ago.
The last couple of months it fails to execute and it throws a 'System.IO.IOException' in mscorlib.dll "Unsupported" when the destination files exists.
My target framework is 4.7.2
I tried to change target framework to 4.6.2 in case an update of NET framework broke it, but still I have the same issue.
Right now I had to temporarily bypass the problem like this:
If My.Computer.FileSystem.FileExists("D:\Temp\Destination.log") Then
My.Computer.FileSystem.DeleteFile("D:\Temp\Destination.log", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
End If
My.Computer.FileSystem.CopyFile("D:\Temp\Origin.log", "D:\Temp\Destination.log", True)
While the above code works, it defeats the purpose of having an overwrite overload (which is still supported in 4.7.2 AFAIK)
Also it means I have to change it in far too many places inside my application code.
Does anyone knows why my original code stopped working, or better yet, how to fix it ?
Edit:
Exception Stack:
System.IO.IOException
HResult=0x80070032
Message=The request is not supported.
Source=mscorlib
StackTrace:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost)
at Microsoft.VisualBasic.FileIO.FileSystem.CopyOrMoveFile(CopyOrMove operation, String sourceFileName, String destinationFileName, Boolean overwrite, UIOptionInternal showUI, UICancelOption onUserCancel)
at Microsoft.VisualBasic.MyServices.FileSystemProxy.CopyFile(String sourceFileName, String destinationFileName, Boolean overwrite)
at KT_Scan_Docs_Manager.Frm_Main.CreateFilelist(Int32 Meleti) in C:\Users\GTsag\Dropbox\Visual Studio\KT2-14 Scan Docs Manager\KT2-14 Scan Docs Manager\frm_Main.vb:line 2880
at KT_Scan_Docs_Manager.Frm_Main.Bt_KT214CreateFileList_Click(Object sender, EventArgs e) in C:\Users\GTsag\Dropbox\Visual Studio\KT2-14 Scan Docs Manager\KT2-14 Scan Docs Manager\frm_Main.vb:line 148
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.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(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 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at KT_Scan_Docs_Manager.My.MyApplication.Main(String[] Args) in :line 81

Visual basic with external .ocx control => access violation

I'm new to this site and I'm going to start immediately with a question.
Currently I'm working on a thesis but I'm a stuck at this moment. I've been asked to control an IP-camera via Beckhoff Twincat3. As this is based on visual studio, I thought it might be a good idea to start in visual basic to test and debug everything I code. Everything I do results in AccessViolation.
System.AccessViolationException was unhandled
HResult=-2147467261
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=mscorlib
StackTrace:
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at RASplus_WatSearLib._DRASplus_WatSear.setCameraMap(Int16 nCamNum, Int16 postKey, String szSiteName, String szAddr, Int16 nHostCam, String szUser, String szPasswd, Int16 port, Boolean mode, Boolean bUseModem, Boolean useDvrns, String szDvrnsAddr, Int16 dvrnsPort, Int16 audioPort)
at AxRASplus_WatSearLib.AxRASplus_WatSear.setCameraMap(Int16 nCamNum, Int16 postKey, String szSiteName, String szAddr, Int16 nHostCam, String szUser, String szPasswd, Int16 port, Boolean mode, Boolean bUseModem, Boolean useDvrns, String szDvrnsAddr, Int16 dvrnsPort, Int16 audioPort)
at activex_camera.Form1.Button1_Click(Object sender, EventArgs e) in C:\Users\BECKHOFF stage\documents\visual studio 2010\Projects\activex camera\activex camera\Form1.vb:line 41
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.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(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.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at activex_camera.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly 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.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
I'm currently trying to connect with the camera and it results each time in a AccessViolation.
myCam.setCameraMap(i, CShort(0), "10.199.217.144", "10.199.217.144", i, "admin", "", CShort(8016), False, False, False, "dvrnames.net", 10088, 8116)
I hope someone can get me back on track. If .ocx or other files needed, please do not hesitate to contact me.
I asked my teacher if he knew what was wrong and he came up with this :
In the program, I was working with an 'instance' of the activex-control. This resulted in a accessviolation. He fixed it by using the direct control.
After all it made sense. ;)
Sincerely
GiovanniVanAssche

Running sql script from Windows Forms Application

I am building a VB.NET desktop application in VS2013 that uses a .mdf file created in SQL Server 2012. I have the .mdf file imported in to the application. Along with the datagridviews I am using to view/modify the database tables I need to execute a SQL script when the user clicks on a button.
I have been trying several examples I've found, without any luck. I'm getting a FileLoadException error on the ExecuteNonQuery line:
An unhandled exception of type 'System.IO.FileLoadException' occurred
in mscorlib.dll
Additional information: Mixed mode assembly is built against version
'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime
without additional configuration information.
The "Troubleshooting tips" section has "Make sure that the file is a valid .NET Framework assembly". I clicked on that link, but the information there isn't very helpful to me, as I really am not understanding what it's saying.
I've tried these two examples so far:
Dim sqlScript As String = "C:\HL_Time_Entry_Reporting\SQL Scripts\stage_employee_hours_load.sql"
Dim connString As String = "Server=(LocalDB)\v11.0;Integrated Security=True;AttachDbFilename=C:\HL_Time_Entry_Reporting\Database\hours_analysis.mdf"
Dim connectionString As String = connString,
scriptText As String = sqlScript
Dim sqlConnection As New SqlConnection(connectionString)
Dim svrConnection As New ServerConnection(sqlConnection)
Dim server As New Server(svrConnection)
server.ConnectionContext.ExecuteNonQuery(scriptText)
from this site. And
Dim sqlConnectionString As String = "Server=(LocalDB)\v11.0;Integrated Security=True;AttachDbFilename=C:\HL_Time_Entry_Reporting\Database\hours_analysis.mdf"
Dim file As New FileInfo("C:\HL_Time_Entry_Reporting\SQL Scripts\stage_employee_hours_load.sql")
Dim script As String = file.OpenText().ReadToEnd()
Dim conn As New SqlConnection(sqlConnectionString)
Dim server As New Server(New ServerConnection(conn))
server.ConnectionContext.ExecuteNonQuery(script)
from this site.
One thing is, I'm not confident I have the correct connection string for this. That's the connection string I have for the datagridviews, which works fine, but is that also what I should use to connect for the sql script file as well?
UPDATE
Per request, here is the stack trace:
at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly
assembly, String name, Boolean throwOnError, Boolean ignoreCase,
ObjectHandleOnStack type) at
System.Reflection.RuntimeAssembly.GetType(String name, Boolean
throwOnError, Boolean ignoreCase) at
System.Reflection.Assembly.GetType(String name, Boolean throwOnError)
at
Microsoft.SqlServer.Management.Common.ServerConnection.GetStatements(String
query, ExecutionTypes executionType, Int32& statementsToReverse) at
Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String
sqlCommand, ExecutionTypes executionType) at
Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String
sqlCommand) at test.main.btnLoadMasterData_Click(Object sender,
EventArgs e) in C:\Users\marky\Documents\Visual Studio
2013\Projects\Hours Analysis\Hours Analysis\Form1.vb:line 212 at
System.Windows.Forms.Control.OnClick(EventArgs e) at
System.Windows.Forms.Button.OnClick(EventArgs e) at
System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at
System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks) at
System.Windows.Forms.Control.WndProc(Message& m) at
System.Windows.Forms.ButtonBase.WndProc(Message& m) at
System.Windows.Forms.Button.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(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.Run(ApplicationContext context) at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[]
commandLine) at test.My.MyApplication.Main(String[] Args) in
17d14f5c-a337-4978-8281-53493378c1071.vb:line 81 at
System.AppDomain._nExecuteAssembly(RuntimeAssembly 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.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx) at
System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx) at
System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state) at
System.Threading.ThreadHelper.ThreadStart()
UPDATE #2
As suggested, I added the startup tag in this SO question to my appconfig file but got a new error on the line "Dim server As New Server(New ServerConnection(conn))" in the second code example. It's a TypeInitializationException. Here's the info:
An unhandled exception of type 'System.TypeInitializationException'
occurred in System.Data.dll
Additional information: The type initializer for
'System.Data.SqlClient.SqlConnection' threw an exception.
Stack trace:
at System.Data.SqlClient.SqlConnection..ctor() at
System.Data.SqlClient.SqlConnection..ctor(String connectionString,
SqlCredential credential) at
System.Data.SqlClient.SqlConnection..ctor(String connectionString)
at test.main.btnLoadMasterData_Click(Object sender, EventArgs e) in
C:\Users\marky\Documents\Visual Studio 2013\Projects\Hours
Analysis\Hours Analysis\Form1.vb:line 210 at
System.Windows.Forms.Control.OnClick(EventArgs e) at
System.Windows.Forms.Button.OnClick(EventArgs e) at
System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at
System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks) at
System.Windows.Forms.Control.WndProc(Message& m) at
System.Windows.Forms.ButtonBase.WndProc(Message& m) at
System.Windows.Forms.Button.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(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.Run(ApplicationContext context) at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[]
commandLine) at test.My.MyApplication.Main(String[] Args) in
17d14f5c-a337-4978-8281-53493378c1071.vb:line 81 at
System.AppDomain._nExecuteAssembly(RuntimeAssembly 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.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx) at
System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx) at
System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state) at
System.Threading.ThreadHelper.ThreadStart()
It looks like you may be using an obsolete version of the SMO library, as explained here: https://stackoverflow.com/a/11286124/109122.
Update:
If the config setting recommended at the link does not work, try this simpler one instead:
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
Unfortunately, it appears that the config file changes do not fix all cases.

Source Safe check in not allowing LABEL assignment

I am trying to apply a LABEL (not a comment, which works) to a VSSItem just prior to check in of a visual source safe file.
I have tested a number of parameters, checked file type etc.
I can correctly check in the file with no issues and add the comment which is a property of the checkin method. What I am unable to do is add the label....
vssItem.Label(msg1, msg2)
msg1 and msg2 are just strings defined above the for stmt.
For Each vssItem As IVSSItem In vssFolder.Items(False)
Console.Write(" {0}", vssItem.Name)
Dim localPCpath As String = "C:\..\..\Projects\test\newtest"
Dim localpath As String = Path.Combine(localPCpath, Path.GetFileName(vssItem.Name))
**vssItem.Label(msg1, msg2)**
vssItem.Checkin("Test 11 of checkin with label", localpath)
If DirectCast(vssItem.IsCheckedOut, VSSFileStatus) = VSSFileStatus.VSSFILE_NOTCHECKEDOUT Then
Console.WriteLine(vssItem.Spec + " is checked in.")
Else
Console.WriteLine(vssItem.Spec + " is checked out.")
End If
Next
The error reported is....
System.Runtime.InteropServices.COMException was unhandled
ErrorCode=-2147352566
HelpLink="ssusexp.hlp#10170"
Message="Invalid access code (bad parameter)."
Source="SourceSafe"
StackTrace:
at Microsoft.VisualStudio.SourceSafe.Interop.IVSSItem.Label(String Label, String Comment)
at DBConversionUpdate.testSS.Button2_Click(Object sender, EventArgs e) in C:\..\..\Documents\Visual Studio 2008\Projects\DBConversionUpdate\DBConversionUpdate\testSS.vb:line 209
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.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 DBConversionUpdate.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()
InnerException:
Let me also say, I know this is old software and many feel that MS Source Safe is junk, but I am stuck with it for now.