This project is read-only.

Dependency Checker - Unauthorized Exception

Topics: Setup / Configuration
Jun 3, 2008 at 8:51 AM
I am logged in to the VISTA machine with  administrator privilege. When I try to execute the Dependency Checker it fails with Unauthorized Exception.

System.UnauthorizedAccessException
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at System.Management.ManagementObjectCollection.ManagementObjectEnumerator.MoveNext()
   at DependencyTest.Helpers.OperatingSystem.GetOsBuild() in D:\Dinnernow\common\DC1\DependencyTest\Helpers\OperatingSystem.cs:line 13
   at DependencyTest.Helpers.Check.GetOsBuild() in D:\Dinnernow\common\DC1\DependencyTest\Helpers\Check.cs:line 11
   at DC1.DC1Gui.LoadDependencyConfig(DependenciesSection section) in D:\Dinnernow\common\DC1\DC1\DC1Gui.cs:line 52
   at DC1.DC1Gui.Scan() in D:\Dinnernow\common\DC1\DC1\DC1Gui.cs:line 35
   at DC1.DC1Gui.DC1Gui_Load(Object sender, EventArgs e) in D:\Dinnernow\common\DC1\DC1\DC1Gui.cs:line 22
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   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.WmShowWindow(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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

The following are the lines of code in the GetOsBuild method.

public static int GetOsBuild()
        {
 ManagementObjectSearcher searcher = WmiHelper.RunWMIQuery("win32_operatingsystem");
            foreach(ManagementObject mo in searcher.Get())
            {
                return int.Parse(mo.SystemProperties["BuildNumber"].Value.ToString());
            }
            return 0;
}

Any help on this is appreciated
Thanks in Advance
-karthik