Add-in performance can be improved by using domain-neutral loading for the pipeline contract. Activation can be improved by generating native images for pipeline segments.
Domain-Neutral Loading Improves Cross-Domain Calls
When an add-in is loaded into a separate application domain, calls between the host and the add-in are marshaled across the application domain boundary by the pipeline. The performance of these cross-domain calls is significantly improved if the assembly that contains the contract is loaded as domain-neutral.
The assembly must have a strong name and must be installed in the global assembly cache, and it must have the LoaderOptimizationAttribute with either the LoaderOptimization.MultiDomainHost flag or the LoaderOptimization.MultiDomain flag.
Avoiding the JIT Compiler Improves Activation
The just-in-time (JIT) compiler adds substantially to the performance overhead of add-in activation, especially when the add-in is activated in a separate application domain. To avoid using the JIT compiler, follow these guidelines:
Give your pipeline assemblies strong names, and install them in the global assembly cache.
Use the Ngen.exe (Native Image Generator) to create native images for your pipeline assemblies.
Make sure that the assembly that contains the contract is loaded as domain-neutral, as described in the previous section.
This point is extremely important. If the contract is not loaded as domain-neutral, none of the add-in-side components can use native images.
Apply the LoaderOptimizationAttribute to the host assembly with either the MultiDomainHost flag or the MultiDomain flag, to allow native images of the .NET Framework assemblies to be shared across application domains.
This performance improvement will not be detectable when running under the debugger, because the hosting process (vshost.exe) is not set up for assembly sharing. You can disable the hosting process, but this is not recommended. Performance should not be measured when running under the debugger.