GetHostObject() returning NULL

Latest post 04-13-2008 9:03 PM by Gary. 4 replies.
  • 04-11-2008 12:47 PM

    • Terry
    • Top 10 Contributor
    • Joined on 05-10-2006
    • Posts 77

    GetHostObject() returning NULL

    With a couple samples working I'm in the middle of creating something for the real world.  So far everything has been relatively predictible until I get to the call to GetHostObject(), which is returning NULL.  Specifically, the following line in the Proxy.cs:

    this.remoteObject = this.providerHost.GetHostObject(...)

    As I step through this line of code it naturally jumps into my HostItemProvider Class, which checks the incoming type and returns an instance of my Host Item.  Unfortunately, after the call recturns I check the value of this.remoteObject and it's "null".

    Now I've seen this before when there's a problem with not matching the type passed in, or if I return a reference to an object that's set to "nothing".  What's driving my completely nuts is that I am stepping line-by line through my GetHostObject() method and when I get to the End Function statement, I hover over the GetHostObject function name, and it IS populated with a valid object.  Then I step out of the method and back into the Proxy.cs and check this.remoteObject, and it's "null" so I end up failing the check for null and ultimately get the "Failed to get host object during Entry Point creation".

    I must say I've never seen anything like this before.  I'm assuming it has something to do with all the magic going on in the pipeline / proxy object translation stuff, but I'm at a loss.  I'm doing this all in one solution with a couple projects with no frills.

    I'll keep poking and simplifying things until I get something to work, but if anyone has a guess, I'm all ears.

    Snowball thrown...

    Thx.

     

  • 04-11-2008 1:04 PM In reply to

    • Terry
    • Top 10 Contributor
    • Joined on 05-10-2006
    • Posts 77

    Re: GetHostObject() returning NULL

    Some progress...

    My HostItem class inherits from a class in another project.  Aafter removing the Inherits statement and just using the class by itself it seemed to make it though the translation process.

    Is there a step I'm missing to make the pipeline aware of my HostItem's  base class?  It's in a different project, so It's not mentioned anywhere in the OM.xml or Proxy.cs.

    Thx.

  • 04-11-2008 2:02 PM In reply to

    • Terry
    • Top 10 Contributor
    • Joined on 05-10-2006
    • Posts 77

    Re: GetHostObject() returning NULL

    Look at me, I'm a virtual blogger...

    Anyhow, I had a thought stuck in the back of my head that made me think I had read about base classes somewhere in the SDK doco so I started reading.  I came across this section that appears to be the source of my problem, though I haven't tested it yet.  Once I have I'll report back:

    "However, if the host class derives from a class in a different assembly and the base class does not have MarshalByRefObject in its inheritance hierarchy, then ProxyGen.exe does not derive the proxy class from MarshalByRefObject. ProxyGen.exe displays an error to warn you that the proxy class is not a usable proxy. In this case, you must redesign the host application's object model so that the host class or the base class has MarshalByRefObject in its inheritance hierarchy."

    Since I use a custom batch file to handle the busywork of updating all the VSTA stuff when chagnes are made, I probably missed the errors from ProxyGen.

     

  • 04-11-2008 2:58 PM In reply to

    • Terry
    • Top 10 Contributor
    • Joined on 05-10-2006
    • Posts 77

    Re: GetHostObject() returning NULL

    Looks like that was the issue.  Once I inherited my base class from MarshalByRefObject the rest fell into place and I got my Host Object Back.

    Hopefully this thread will be helpfull for someone searching in the future.

    Until next time.

  • 04-13-2008 9:03 PM In reply to

    • Gary
    • Top 10 Contributor
    • Joined on 07-13-2006
    • Posts 306

    Re: GetHostObject() returning NULL

    Great blog, Terry!

    Thanks

Page 1 of 1 (5 items) | RSS
Copyright Summit Software Company, 2008. All rights reserved.