1
我正在使用MAF(System.AddIn)来加载进程外的加载项。我发现,只要Visual Studio在进程树中的任何位置,插件就需要2.5秒才能激活。但是,当Visual Studio不在进程树中时,它只需要大约250-300ms。当Visual Studio在进程树中时AddIn激活缓慢
我使用来测试这个代码是:
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 pipleines和接口,并看到类似的结果。
有谁知道什么会导致Visual Studio启动过程导致性能差距很大?