所以我在OSX上的Mono 3.12.0中运行了一个控制台应用程序.偶尔,我的意思是,也许每100次或更多次执行CleanupPriorToApplicationStart(),我得到下面的堆栈跟踪,并调用清理方法的父线程死掉;基本上Process.Start必须包装本机代码,而本机代码抛出一个异常,至少我认为正在发生这种情况.这个过程保持不变,所以它不是一个完整的退出(),这使得很难知道这种情况何时发生并纠正它.清理方法的日志消息中的异常处理程序永远不会出现在那里,因此无论出于何种原因,单声道运行时都没有将此本机异常包装在.NET / Mono异常中,因此可以对其进行处理.这是预期的吗?有没有办法在没有我的线程被取出的情况下捕获这种行为?
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) <0xffffffff> Native stacktrace:
更新:
解决方法
对我来说看起来像个错误.我在FreeBSD 10.1上运行mono 3.12.1_1也有同样的问题.当GC在错误的时间发生时,你会再次被咬.
我升级到mono 4.0.1.28并且无法重现我的问题.
它也可以解决你的问题.
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) <0x00199> at System.ComponentModel.Component.dispose () <0x00018> ... at (wrapper dynamic-method) object.lambda_method (System.Runtime.CompilerServices.Closure,object,object) <0x00082> at ServiceStack.Host.ServiceRunner`1.Execute (ServiceStack.Web.IRequest,TRequest) <0x00450> at ServiceStack.Host.ServiceRunner`1.Process (ServiceStack.Web.IRequest,object) <0x000cc> at ServiceStack.Host.ServiceExec`1.Execute (ServiceStack.Web.IRequest,string) <0x0012a> at ServiceStack.Host.ServiceRequestExec`2.Execute (ServiceStack.Web.IRequest,object) <0x00076> at ServiceStack.Host.ServiceController/<>c__displayClass11/<>c__displayClass13.<RegisterServiceExecutor>b__10 (ServiceStack.Web.IRequest,object) <0x00040> at ServiceStack.Host.ServiceController.ManagedServiceExec (ServiceStack.Host.ServiceExecFn,ServiceStack.IService,ServiceStack.Web.IRequest,object) <0x001c3> at ServiceStack.Host.ServiceController/<>c__displayClass11.<RegisterServiceExecutor>b__f (ServiceStack.Web.IRequest,object) <0x0023a> at ServiceStack.Host.ServiceController.Execute (object,ServiceStack.Web.IRequest) <0x000e2> at ServiceStack.HostContext.ExecuteService (object,ServiceStack.Web.IRequest) <0x00076> at ServiceStack.Host.Handlers.ServiceStackHandlerBase.ExecuteService (object,ServiceStack.Web.IRequest) <0x00019> at ServiceStack.Host.RestHandler.GetResponse (ServiceStack.Web.IRequest,object) <0x00091> at ServiceStack.Host.RestHandler.ProcessRequestAsync (ServiceStack.Web.IRequest,ServiceStack.Web.IResponse,string) <0x00729> at ServiceStack.AppHostHttpListenerBase.ProcessRequestAsync (System.Net.HttpListenerContext) <0x0030c> at ServiceStack.Host.HttpListener.HttpListenerBase.InitTask (System.Net.HttpListenerContext) <0x0008f> at ServiceStack.AppSelfHostBase/<>c__displayClass2.<ListenerCallback>b__1 () <0x0001e> at Amib.Threading.Internal.WorkItemsGroupBase/<>c__displayClass1.<QueueWorkItem>b__0 (object) <0x00019> at Amib.Threading.Internal.WorkItem.ExecuteWorkItem () <0x00115> at Amib.Threading.Internal.WorkItem.Execute () <0x00065> at Amib.Threading.SmartThreadPool.ExecuteWorkItem (Amib.Threading.Internal.WorkItem) <0x000af> at Amib.Threading.SmartThreadPool.ProcessQueuedItems () <0x006aa> at System.Threading.Thread.StartInternal () <0x0007e> at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr) <0xffffffff> ... ================================================================= Got a SIGSEGV while executing native code. This usually indicates a Fatal error in the mono runtime or one of the native libraries used by your application. =================================================================
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。