WMI SystemRestore InteropServices.COMException Crash. What's wrong?
I have a number of people saying that they are receiving this particular crash.
Function createRestorePoint(strDescription As String, rt As RestoreType, ByRef lSeqNum As Long) As Integer
Dim managementScopeObject As New ManagementScope("\\localhost\root\default")
Dim managementPathObject As New ManagementPath("SystemRestore")
Dim managementObjectOptions As New ObjectGetOptions()
Dim managementClassObject As New ManagementClass(managementScopeObject, managementPathObject, managementObjectOptions)
Dim managementBaseObjectParameters As ManagementBaseObject = managementClassObject.GetMethodParameters("CreateRestorePoint")
managementBaseObjectParameters("Description") = strDescription
managementBaseObjectParameters("RestorePointType") = rt
managementBaseObjectParameters("EventType") = 100
Dim oOutParams As ManagementBaseObject = managementClassObject.InvokeMethod("CreateRestorePoint", managementBaseObjectParameters, Nothing)
Catch ex As Exception
Exception Type: System.Runtime.InteropServices.COMException The exception occurred at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) at System.Management.ManagementObject.InvokeMethod(String methodName, ManagementBaseObject inParameters, InvokeMethodOptions options) at My_Program.createRestorePoint(String strDescription, RestoreType rt, Int64& lSeqNum)
I have been unable to narrow down why this crash is occurring. The code works exactly as intended with absolutely no issues on my desktop, notebook, and several instances of Windows (XP, Vista, 7, 8, and 8.1 Update 1) that I have installed in VirtualBox VMs. I'm tearing my hair out here because I have no earthly idea why this is happening. If it were happening on my own machines I'd be able to track down where the issue is but I can't reproduce this crash on my machines or in my VMs.
What am I doing wrong here?
Re: WMI SystemRestore InteropServices.COMException Crash. What's wrong?
This could really be anywhere in that code, but based on your testing I'm going to say that it's a x86/x64 issue.
Try changing the build platform to x86.
Right click on the solution, select configuration manager. Change the Platform to x86.