1

我正在使用 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 启动该过程导致性能出现如此大的差异?

4

1 回答 1

1

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

于 2015-09-01T02:29:04.947 回答