Add-in in same AppDomain as host

Latest post 04-09-2008 5:06 PM by Gary. 1 replies.
  • 04-09-2008 4:37 AM

    • kentcb
    • Top 50 Contributor
    • Joined on 04-04-2008
    • Posts 4

    Add-in in same AppDomain as host

    Hello,

    I'm trying to activate an add-in in the same AppDomain as the host application using VSTA 2.0. The activation itself succeeds but there are problems that result from the lack of marshalling between add-in and host:
    1. When the add-in calls the GetHostObject() method, it passes a Type from the Proxy assembly, not the Contract assembly. Since no marshalling is happening, the GetHostObject() method receives the type from the proxy assembly and must be modified to check for both the contract type and the proxy type.
    2. When the add-in requests a service from the host, it receives back an implementation of the contract, not the proxy interface. That means the add-in has to be aware of whether it is being activated alongside the host application or not.
    Can you confirm these as issues, and/or suggest a viable workaround?

    Thanks,
    Kent
  • 04-09-2008 5:06 PM In reply to

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

    Re: Add-in in same AppDomain as host

    This sounds likely.  I've not tried it, though.

    The drawback of shared AppDomain is that the add-in is loaded into the same AppDomain, and it cannot be unloaded until the Application unloads.

    // Activate add-in in the same application domain.

    IEntryPoint AddIn =

          selectedToken.Activate<IEntryPoint>(ApplicationAppDom);

    If this is a desireable scenario, I suppose that the workaround would be to test for the common AppDomain and hook up without the generic proxy for the shared AppDomain case.  This would be another situation where a custom contract implementation would workaround and still preserve versioning independence -- I'll try it.

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