Open rpokrovskij opened 6 years ago
Managed injector which is used to force garbage collection on remote process uses the MainWindow handle to identify thread to run external code in it. There is no MainWindow in console application, so this approach doesn't work. I understand that it is a severe limitation. I'll look at this and let you know.
It would be nice to have a solution for WinService and ASP either. It can be a client part (three different client parts that stop app three different ways for a profiling session).
For a console app it can be a requirement to run all code in tasks with specific TaskSchedule (there is genre of C# tooling "write custom async manager for console app" use them as source of inspiration).
.NET Framework 4.7;
There are two console applications: one create "load", other tryies to get profiling information. The second one throws an exception:
System.InvalidOperationException: 'Unable to force GC.Collect on remote process'
at Ascon.NetMemoryProfiler.GarbageCollectorRunner.ForceGarbageCollectionInRemoteProcess(Int32 pid) at Ascon.NetMemoryProfiler.Profiler.AttachToProcess(Int32 pid, UInt32 timeout) at Ascon.NetMemoryProfiler.Profiler.AttachToProcess(String processName, UInt32 timeout) at ProfilerAutomation.Program.Main(String[] args) in D:\cot\DashboardCode\Routines\Tests\ProfilerAutomation\Program.cs:line 14
Code (exception thrown on the first line)