So, I have a console application running in Mono 3.12.0 on OSX. By chance, and I mean, maybe once every 100 or more executions CleanupPriorToApplicationStart(), I get a stacktrace below, and the parent thread that calls the cleanup method dies; basically Process.Start should wrap its own code and this native code throws an exception, at least what I think is happening. The process remains around, so its not a complete way out (), which makes it very difficult to know when it will happen and fix it. The Exception handler in the cleanup method log message never makes it there, so for some reason mono runtime does not wrap this own exception in the .NET / Mono exception, so it can be handled. Is this expected? Is there a way to catch this behavior if my thread is not retrieved?
protected override void CleanupPriorToApplicationStart()
{
try
{
ResetAppleMailDefaultWindowSize();
}
catch (Exception ex)
{
logger.Warning(ex, "{ApplicationName} Default Window Size reset FAILED with message", ApplicationName);
}
}
private void ResetAppleMailDefaultWindowSize()
{
logger.Debug("{0} resetting Default Window Size", ApplicationName);
var info = new ProcessStartInfo("defaults", " write com.apple.mail 'NSWindow Frame Torn Off Window' '13 630 1024 768 0 0 2560 1417'");
var p = new Process {StartInfo = info};
p.Start();
p.WaitForExit(6.Seconds());
logger.Debug("{0} Default Window Size reset", ApplicationName);
}
DEBUG - "Mail" resetting Default Window Size
Stacktrace:
at <unknown> <0xffffffff>
at (wrapper managed-to-native) System.Diagnostics.Process.Process_free_internal (System.Diagnostics.Process,intptr) <0xffffffff>
at System.Diagnostics.Process.Dispose (bool) <0x0013f>
at System.Diagnostics.Process.Finalize () <0x00018>
at (wrapper runtime-invoke) object.runtime_invoke_virtual_void__this__ (object,intptr,intptr,intptr) <0xffffffff>
Native stacktrace:
UPDATE:
- googling , Cleanup Garbage Collection GC.Collect();