我在 Windows XP 上遇到了关于我的应用程序的问题。我在 Windows XP 上收到以下错误,而在 7/8 上它工作正常,我不知道下一步该做什么。我调查了这个问题,发现它与 WMI 有关。我尝试在 Windows XP 系统上修复 WMI,但仍然无法正常工作。
这是我收到的错误:
************** 异常文本 **************
System.Management.ManagementException:在 System.Management.PropertyDataCollection.get_Item(String propertyName) 在 System.Management.PropertyData.RefreshPropertyInfo() 在 System.Management.ManagementBaseObject.GetPropertyValue 中找不到 System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode) (String propertyName) at System.Management.ManagementBaseObject.get_Item(String propertyName)
at ?.?.(Object , EventArgs) at System.Windows.Forms.Timer.OnTick(EventArgs e) at System.Windows.Forms.Timer.TimerNativeWindow .WndProc(Message& m) 在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
winmgmt 服务正在上述系统上运行。有谁知道下一步该怎么做?我目前正在安装 Windows XP 以查明错误,但我可以从该站点更有经验的成员那里获得一些帮助。
这是模拟错误的代码。它在 hdd.Get 循环上停止
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
TextBox1.Text = TextBox1.Text + vbNewLine + "Starting process"
Try
Dim HDD_Serial As String = Nothing
TextBox1.Text = TextBox1.Text + vbNewLine + "Step 1"
Dim hdd As New ManagementObjectSearcher("select * from Win32_DiskDrive")
TextBox1.Text = TextBox1.Text + vbNewLine + "Step 2"
For Each hd In hdd.Get
TextBox1.Text = TextBox1.Text + vbNewLine + "Step 2.x"
HDD_Serial = hd("SerialNumber")
Next
TextBox1.Text = TextBox1.Text + vbNewLine + "Step 3"
HDD_Serial = HDD_Serial.Replace(" ", "")
TextBox1.Text = TextBox1.Text + vbNewLine + "Step 4"
Dim regkey As String = "0000-0000-0000-0000"
TextBox1.Text = TextBox1.Text + vbNewLine + "Step 5"
Dim sstring As String = regkey + "|" + HDD_Serial
TextBox1.Text = TextBox1.Text + vbNewLine + "Step 6"
sstring = AESEncrypt(sstring, "4545664456", "1251545478")
TextBox1.Text = TextBox1.Text + vbNewLine + "Step 7"
sstring = StrToHex(sstring)
TextBox1.Text = TextBox1.Text + vbNewLine + "Step 8"
Dim rk2 As RegistryKey = Registry.LocalMachine.CreateSubKey("SOFTWARE\Test Key")
TextBox1.Text = TextBox1.Text + vbNewLine + "Step 9"
rk2.SetValue("regentry", sstring, RegistryValueKind.String)
TextBox1.Text = TextBox1.Text + vbNewLine + "Step 10"
Catch ex As Exception
MessageBox.Show("Error")
TextBox1.Text = TextBox1.Text + vbNewLine + vbNewLine + "-----------------------------------------------------" + vbNewLine + ex.ToString
End Try
TextBox1.Text = TextBox1.Text + vbNewLine + "End of log"
End Sub
错误图片: