程序'[13476] MyApp.vshost.exe'已退出,代码为-1(0xffffffff)

【程序' [13476] MyApp.vshost.exe' 已退出,代码为-1(0xffffffff)】大道之行,天下为公。这篇文章主要讲述程序' [13476] MyApp.vshost.exe' 已退出,代码为-1(0xffffffff)相关的知识,希望能为你提供帮助。
我有一个项目的输出类型的控制台应用程序,有时我调试时无法启动。发生这种情况时,应用程序可能会开始运行并写入托管正在调试的进程的vshost.exe控制台。然后突然间,我会在“输出”窗口中看到一条消息,上面写着“程序'[13476] MyApp.vshost.exe'已退出,代码为-1(0xffffffff)。”
它不会每次都发生,但是当它进入控制台窗口时,我的应用程序在屏幕上冻结启动,调试器似乎停止了。但是,vshost.exe进程实际上并没有停止(我可以在任务管理器中看到它与错误消息具有相同的进程ID)。就好像Visual Studio认为这个过程已经退出,但实际上并没有。当我停止调试器时,控制台窗口也会在屏幕上保持冻结状态。让调试器再次工作的唯一方法是关闭并重新启动VS.
如果我关闭了Visual Studio托管过程,也会发生这种情况。应用程序在Main方法中只有一个退出点,当发生这种情况时,不会触发该行代码上的断点。
我无法弄清楚如何更详细地了解为什么会发生这种情况以进一步排除故障。我已将代码放在AppDomain.CurrentDomain.UnhandledExcpetion处理程序以及Application.ApplicationExit处理程序中,但是在出现此问题时它们不会被命中。我也没有在Windows事件日志中看到任何内容等。
输出窗口示例

...
'MyApp.vshost.exe'(CLR v4.0.30319:MyApp.vshost.exe):已加载'C: WindowsMicrosoft.NetassemblyGAC_MSILSystem.IdentityModelv4.0_4.0.0.0__b77a5c561934e089System.IdentityModel .dll文件”。无法找到或打开PDB文件。
'MyApp.vshost.exe'(CLR v4.0.30319:MyApp.vshost.exe):已加载'C: WindowsMicrosoft.NetassemblyGAC_MSILSystem.ServiceModel.Webv4.0_4.0.0.0__31bf3856ad364e35System .ServiceModel.Web.dll”。无法找到或打开PDB文件。
'MyApp.vshost.exe'(CLR v4.0.30319:MyApp.vshost.exe):已加载'C: WindowsMicrosoft.NetassemblyGAC_MSILMicrosoft.VisualStudio.Diagnostics.ServiceModelSinkv4.0_4.0.0.0__b03f5f7f11d50a3aMicrosoft.VisualStudio.Diagnostics.ServiceModelSink.dll”。无法找到或打开PDB文件。
'MyApp.vshost.exe'(CLR v4.0.30319:MyApp.vshost.exe):已加载'C: WindowsMicrosoft.NetassemblyGAC_MSILSystem.Net.Httpv4.0_4.0.0.0__b03f5f7f11d50a3aSystem .Net.Http.dll”。跳过加载符号。模块已经过优化,调试器选项“Just My Code”已启用。
线程0xf18已退出,代码为259(0x103)。
线程0x2928已退出,代码为259(0x103)。
线程0x3654已退出代码259(0x103)。
程序'[13476] MyApp.vshost.exe'已退出,代码为-1(0xffffffff)。
答案我在事件日志中找到了以下事件。然而,它在一个奇怪的地方我从未在事件查看器 - > 自定义视图 - > 管理事件之前查看。这导致我到MS KB http://support.microsoft.com/kb/2773443。
MyApp项目的目标是.NET 4.0,我最近在我的笔记本电脑(.NET 4.5)上安装了Visual Studio 2013,这是在问题开始发生的时候。所以我认为这是我的问题。
我不明白的是,为什么这个异常没有在我的MyApp项目中引发AppDomain.UnhandledExcpetion事件,而是以静默方式终止进程。导致此问题的WCF服务是从正在启动的新线程启动的,但我认为此线程中的异常仍应引发AppDomain.UnhandledExcpetion事件。我验证了UndhandledException处理程序正在我的应用程序中工作。
为解决这个问题,我已将此服务的启动移至其面向.NET 3.5和x86的项目。这更模仿我们如何在生产中运行应用程序,因此它适用于我。 Microsoft KB中还有一个补丁和各种解决方法。
我希望这对某人有所帮助,我正在试图弄清楚如何得到导致我的问题的异常。
Log Name:Application Source:.NET Runtime Date:1/21/2014 9:09:23 AM Event ID:1026 Task Category: None Level:Error Keywords:Classic User:N/A Computer:DUDELT Description: Application: MyApp.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.ServiceModel.AddressAlreadyInUseException Stack: at System.ServiceModel.Channels.TransportManager.Open(System.ServiceModel.Channels.TransportChannelListener) at System.ServiceModel.Channels.TransportManagerContainer.Open(System.ServiceModel.Channels.SelectTransportManagersCallback) at System.ServiceModel.Channels.TransportChannelListener.OnOpen(System.TimeSpan) at System.ServiceModel.Channels.ConnectionOrientedTransportChannelListener.OnOpen(System.TimeSpan) at System.ServiceModel.Channels.TcpChannelListener`2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].OnOpen(System.TimeSpan) at System.ServiceModel.Channels.CommunicationObject.Open(System.TimeSpan) at System.ServiceModel.Channels.ReliableChannelListenerBase`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].OnOpen(System.TimeSpan) at System.ServiceModel.Channels.CommunicationObject.Open(System.TimeSpan) at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(System.TimeSpan) at System.ServiceModel.Channels.CommunicationObject.Open(System.TimeSpan) at System.ServiceModel.ServiceHostBase.OnOpen(System.TimeSpan) at System.ServiceModel.Channels.CommunicationObject.Open(System.TimeSpan) at System.ServiceModel.Channels.CommunicationObject.Open() at MyApp32.MyApp32.Main() at System.Threading.ThreadHelper.ThreadStart_Context(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Threading.ThreadHelper.ThreadStart()Event Xml: < Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> < System> < Provider Name=".NET Runtime" /> < EventID Qualifiers="0"> 1026< /EventID> < Level> 2< /Level> < Task> 0< /Task> < Keywords> 0x80000000000000< /Keywords> < TimeCreated SystemTime="2014-01-21T14:09:23.000000000Z" /> < EventRecordID> 287767< /EventRecordID> < Channel> Application< /Channel> < Computer> DUDELT< /Computer> < Security /> < /System> < EventData> < Data> Application: MyApp.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.ServiceModel.AddressAlreadyInUseException Stack: at System.ServiceModel.Channels.TransportManager.Open(System.ServiceModel.Channels.TransportChannelListener) at System.ServiceModel.Channels.TransportManagerContainer.Open(System.ServiceModel.Channels.SelectTransportManagersCallback) at System.ServiceModel.Channels.TransportChannelListener.OnOpen(System.TimeSpan) at System.ServiceModel.Channels.ConnectionOrientedTransportChannelListener.OnOpen(System.TimeSpan) at System.ServiceModel.Channels.TcpChannelListener`2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].OnOpen(System.TimeSpan) at System.ServiceModel.Channels.CommunicationObject.Open(System.TimeSpan) at System.ServiceModel.Channels.ReliableChannelListenerBase`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].OnOpen(System.TimeSpan) at System.ServiceModel.Channels.CommunicationObject.Open(System.TimeSpan) at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(System.TimeSpan) at System.ServiceModel.Channels.CommunicationObject.Open(System.TimeSpan) at System.ServiceModel.ServiceHostBase.OnOpen(System.TimeSpan) at System.ServiceModel.Channels.CommunicationObject.Open(System.TimeSpan) at System.ServiceModel.Channels.CommunicationObject.Open() at MyApp32. MyApp 32.Main() at System.Threading.ThreadHelper.ThreadStart_Context(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Threading.ThreadHelper.ThreadStart() < /Data> < /EventData> < /Event> Log Name:Application Source:Application Error Date:1/21/2014 9:09:23 AM Event ID:1000 Task Category: (100) Level:Error Keywords:Classic User:N/A Computer:DUDELT Description: Faulting application name: MyApp.exe, version: 0.0.0.0, time stamp: 0x52dd9b89 Faulting module name: KERNELBASE.dll, version: 6.1.7601.18229, time stamp: 0x51fb1116 Exception code: 0xe0434352 Fault offset: 0x0000c41f Faulting process id: 0x3ac0 Faulting application start time: 0x01cf16b23d49d636 Faulting application path: C:MyAppMyAppinDebugMyApp.exe Faulting module path: C:Windowssyswow64KERNELBASE.dll Report Id: a0b3e605-82a5-11e3-ab71-0021cc6f2033 Event Xml: < Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> < System> < Provider Name="Application Error" /> < EventID Qualifiers="0"> 1000< /EventID> < Level> 2< /Level> < Task> 100< /Task> < Keywords> 0x80000000000000< /Keywords> < TimeCreated SystemTime="2014-01-21T14:09:23.000000000Z" /> < EventRecordID> 287768< /EventRecordID> < Channel> Application< /Channel> < Computer> DUDELT< /Computer> < Security /> < /System> < EventData> < Data> MyApp.exe< /Data> < Data> 0.0.0.0< /Data> < Data> 52dd9b89< /Data> < Data> KERNELBASE.dll< /Data> < Data> 6.1.7601.18229< /Data> < Data> 51fb1116< /Data> < Data> e0434352< /Data> < Data> 0000c41f< /Data> < Data> 3ac0< /Data> < Data> 01cf16b23d49d636< /Data> < Data> C:codeMyAppMyAppinDebugMyApp.exe< /Data> < Data> C:Windowssyswow64KERNELBASE.dll< /Data> < Data> a0b3e605-82a5-11e3-ab71-0021cc6f2033< /Data> < /EventData> < /Event>

另一答案我遇到了同样的问题,它看起来像.net未记录的问题。但您可以按照以下方式缓解它:
  • 找到失败的代码部分,然后按照您尝试阅读的类进行操作。
  • 为该类添加默认构造函数。在某些情况下,序列化需要一个默认构造函数来创建对象,这是实际问题。
<

    推荐阅读