April 24th, 2014, 11:33 PM
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?
May 6th, 2014, 10:17 AM
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.
- CRG IT Solutions
- Microsoft Gold Partner
-My posts after 11/2011 = .NET 4.x and Visual Studio 2012
-My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
-My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
-My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
-My posts before 04/2007 = .NET 1.1/2.0
*I do not follow threads, so if you have a secondary question, message me.
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!