EnableDirectConnect problem

Feb 8, 2008 at 12:30 AM

I am trying to get EnableDirectConnect to work - it doesn't seem to be doing what I expect. Here's a chunk of the code in the host app:

String[] result1 = AddInStore.Update(pipelineRoot);
AddInToken.EnableDirectConnect = true;

addInTokens = AddInStore.FindAddIns(typeof(IWorkspaceComponentController), pipelineRoot);
foreach (AddInToken token in addInTokens)
{
IWorkspaceComponentController item = token.Activate<IWorkspaceComponentController>(System.AppDomain.CurrentDomain);
IWorkspaceComponent control = item.CreateControl();
System.Windows.Forms.Control a = control as System.Windows.Forms.Control;
}

Since the add-in is running in the same app-domain as the host, and since the host and add-in views are identical (except for the AddInBase attribute on the interface in the add-in view), I would expect that the type of item would not be a HostSideAdapter, but it is. I tried changing the code so the host was actually using the add-in view instead of the host view; it compiles, but then FindAddIns doesn't find anything. I guess I expected this somewhat - doesn't seem like the pipeline discovery code would like pieces at two points in the pipeline having AddInBase attributes.

However, I'm not entirely sure what this statement means in the description of EnableDirectConnect:

For Hosts and Add-in’s having the same view of each other (e.g., in V1) that forgo unloadability and share the same security context (i.e., run in the same AppDomain), you can choose to optimize the Add-In loading behavior (AddInToken.EnableDirectConnect) by not instantiating the Adapters.


Any clarification would be greatly appreciated!
Feb 8, 2008 at 7:34 AM
There has been some confusion about this feature, we'll take a look at the docs and see what we can do to clarify it a bit.

When it means they must "have the same view" it means that the assemblies/types must be exactly the same (not just look the same). To do this you only build a single view assembly (with the addinbase attribute on the appropriate type inside it) and have everything that would reference a view refernce that view. You'll need to copy that assembly to both the AddInViews directory and the host directory (so the host can reference it before the add-in gets loaded). Once you do that you should be set.

If you are using the PipelineBuilder you can apply the "PipelineHints.ShareViews" attribute on your contract assembly and it will automatically build a single view and set everything up appropriately for you.