Share via


Add-In Performance

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.

    Note

    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.

    Note

    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.

See Also

Reference

LoaderOptimizationAttribute

LoaderOptimization

Ngen.exe (Native Image Generator)

Concepts

Application Domains and Assemblies