locked
Can't access WHSInfoClass in SDK sample RRS feed

  • Question

  • I'm trying to teach myself how to write an add-in and I can't seem to get the WHSInfoClass object to work for me.  Here's the code:

     

    Imports System.Drawing
    Imports System.Windows.Forms
    Imports Microsoft.HomeServer.SDK.Interop.v1
    Imports Microsoft.HomeServer.Extensibility

    Public Class HomeServerTabExtender
        Implements IConsoleTab

        Private consoleServices As IConsoleServices
        Private m_tabControl As MainTabUserControl
        Private myWhsInfo As WHSInfoClass

        Public Sub New(ByVal width As Integer, ByVal height As Integer, ByVal consoleServices As IConsoleServices)
            Me.m_tabControl = New MainTabUserControl()
            Me.consoleServices = consoleServices
            myWhsInfo = New WHSInfoClass() 

        End Sub

        'Other code redacted for simplicity
    End Class

    The line myWhsInfo = New WHSInfoClass() gives this exception at runtime (BTW, I'm using Brendan Grant's WHSTestLoader to execute this on my XP dev machine, if that makes any difference):

     

    System.Exception was unhandled
      Message="Could not create instance: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {99BDE280-300D-4016-9382-F86E16AA0DBB} failed due to the following error: 80040154.

       at Microsoft.HomeServer.HomeServerConsoleTab.WHSTest.HomeServerTabExtender..ctor(Int32 width, Int32 height, IConsoleServices consoleServices) in \\\\server\\Users\\Jody\\My Documents\\Visual Studio 2005\\Projects\\WHSTest\\WHSTest\\HomeServerTabExtender.vb:line 16

       --- End of inner exception stack trace ---

       at System.RuntimeMethodHandle._InvokeConstructor(Object[] args, SignatureStruct& signature, IntPtr declaringType)

       at System.RuntimeMethodHandle.InvokeConstructor(Object[] args, SignatureStruct signature, RuntimeTypeHandle declaringType)

       at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

       at System.Reflection.ConstructorInfo.Invoke(Object[] parameters)\r\n   at WhsTestLoader.TestLoader.GetExtender(Assembly a, ExtenderType extenderType, String tabName)"
      Source="WhsTestLoader"
      StackTrace:
           at WhsTestLoader.TestLoader.GetExtender(Assembly a, ExtenderType extenderType, String tabName)
           at WhsTestLoader.TestLoader.TestAssembly(String path)
           at WhsTestLoader.TestLoader.TestLoader_Load(Object sender, EventArgs e)
           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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
           at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
           at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
           at System.Windows.Forms.Control.set_Visible(Boolean value)
           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(Form mainForm)
           at WhsTestLoader.Program.Main()

    If I take out that line of code, it compiles and runs just fine, so I know my references to the WHS DLLs are correct.

     

    Any thoughts?

    Saturday, January 12, 2008 8:42 PM

All replies


    • WHSInfo is a class used to access information about your Windows Home Server.
    • You are running your test program on XP.

    Can you see why the problem may be occuring? Smile

    I do a lot of my development under XP in my lunch hour at work where running a virtual server isn't feasible. To make it easier, I wrote a little class that wraps WHSInfo. If I'm running under XP (detected by checking the Windows version) it returns dummy-but-sensible data instead of using WHSInfo.

    Andrew

    Saturday, January 12, 2008 9:29 PM
  • If that's the case, why does the SDK plainly indicate that the DLL operates under XP for development purposes?  And why am I not finding anyone else having this problem while they develop add-ins?

     

    So I guess the real question is whether anyone has this working on a development machine?

    Sunday, January 13, 2008 4:40 AM
  •  jfarr wrote:

    If that's the case, why does the SDK plainly indicate that the DLL operates under XP for development purposes?  And why am I not finding anyone else having this problem while they develop add-ins?

     

    So I guess the real question is whether anyone has this working on a development machine?


    You can develop using WHSInfoClass on Windows XP, but the design of the SDK is that the add-in that is created be run on the Windows Home Server, and either integrated into the console or into an application designed to run on Windows Home Server.

    While the TabTest loader simulates the loading of the tab, it does not simulate obtaining information from a Windows Home Server, so you will have to use a Windows Home Server to test the add-in.

    Sunday, January 13, 2008 6:43 AM
    Moderator
  • Okay, I guess that makes sense.  However, I figured in that case that the failure would occur later when I try to use the class to look something up, not when I just instantiate it.

     

    Thanks, gang!

     

    Sunday, January 13, 2008 2:18 PM