Visual Studio 在进程树中时加载项激活速度变慢

AddIn Activation Slow when Visual Studio is in the Process Tree

我正在使用 MAF (System.AddIn) 从进程中加载​​插件。我发现只要 Visual Studio 位于进程树中的任何位置,插件就会花费超过 2.5 秒的时间来激活。然而,当 Visual Studio 不在进程树中时,它只需要大约 250-300 毫秒。

我用来测试的代码是:

private void OneProcPerAddIn()
{
    var addins = System.AddIn.Hosting.AddInStore.FindAddIns(typeof(IMyAddInInterface),
         PipelineStoreLocation.ApplicationBase);

    foreach (var addin in addins)
    {

        Stopwatch sw = new Stopwatch();
        sw.Start();
        var proc = new AddInProcess();
        var p = addin.Activate<IMyAddInInterface>(proc, securityLevel);
        sw.Stop();

        Log("Took {0} ms to load the addin {1}", sw.Elapsed.TotalMilliseconds, addin.AssemblyName);

        providers.Add(p);
    }
}

此延迟发生在调试或发布时,但仅当执行该激活的进程由 Visual Studio 启动时才会发生。我是否附加调试器似乎并不重要。如果我在 Visual Studio 中将可执行文件设置为工具并以这种方式启动它,就会发生这种情况。

如果我 运行 在 Visual Studio 之外使用完全相同的可执行文件,那么我会看到启动时间有所改善。

这就是为什么我似乎认为只有当 Visual Studio 在进程树中时才是问题。

我已经尝试使用不同的 MAF 管道和接口进行此操作,并看到类似的结果。

有谁知道什么会导致 Visual Studio 启动进程导致如此大的性能差异?

这是旧版本 Visual Studio 中的问题,但在 Visual Studio 2015 中不再存在。升级到 VS 2015 后问题就会消失。