When running multiple tests sequential, in each of the tests a ProfilerApplicationCore is created, and sometimes we have the exception:
Message:
System.InvalidOperationException : Cannot change default WinStoreHelper.
Stack Trace:
WinStoreHelper.InitDefault(WinStoreHelper winStoreHelper)
ProfilerApplicationCore.ctor()
Code: Select all
public void ExampleTest()
{
ProfilerApplicationCore application = new ProfilerApplicationCore();
var process = Process.GetProcessesByName("TestApp").First();
int processId = process.Id;
// Using ProfilingType.Attach to attach to a process.
// The name argument is just used for presentation. The process id must be specified explicitly.
var profileProcessStartInfo = new ProfileProcessStartInfo(ProfilingType.Attach, "FARO.CAM2.exe")
{
ProcessId = processId, AttachType = AttachType.NoAPI, UseDumpFile = true
};
using ActiveSession activeSession = application.CreateSession(profileProcessStartInfo);
// Start it
activeSession.Start(TimeSpan.FromMinutes(5));
// Collect a snapshot
activeSession.CollectSnapshot(SnapshotCollection.None);
//Do stuff on TestApp
// Collect a snapshot
activeSession.CollectSnapshot(SnapshotCollection.None);
// And stop it
activeSession.Stop();
}
Ricardo