【问题标题】:The program '[13476] MyApp.vshost.exe' has exited with code -1 (0xffffffff)程序“[13476] MyApp.vshost.exe”已退出,代码为 -1 (0xffffffff)
【发布时间】:2014-01-17 19:56:39
【问题描述】:

我有一个输出类型为控制台应用程序的项目,当我调试时有时无法启动。发生这种情况时,可能应用程序开始运行并写入托管正在调试的进程的 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:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.IdentityModel\v4.0_4.0.0.0__b77a5c561934e089\System.IdentityModel.dll'。 无法找到或打开 PDB 文件。

“MyApp.vshost.exe”(CLR v4.0.30319:MyApp.vshost.exe):已加载 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Web\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll'。 无法找到或打开 PDB 文件。

“MyApp.vshost.exe”(CLR v4.0.30319:MyApp.vshost.exe):已加载 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.VisualStudio.Diagnostics.ServiceModelSink\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Diagnostics.ServiceModelSink.dll'。 无法找到或打开 PDB 文件。

“MyApp.vshost.exe”(CLR v4.0.30319:MyApp.vshost.exe):已加载 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Net.Http.dll'。 跳过加载符号。模块经过优化和调试器选项 “仅我的代码”已启用。

线程 0xf18 已退出,代码为 259 (0x103)。

线程 0x2928 已退出,代码为 259 (0x103)。

线程 0x3654 已退出,代码为 259 (0x103)。

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

【问题讨论】:

  • 您所描述的对于VS2013来说都是正常的,我看到这些退出代码也可以完美地正常执行程序。 vshost.exe不退出是正常的。只需使用一个无所事事的新控制台模式项目来尝试它。这不会让任何人猜测您的程序行为异常的原因。
  • 我不担心线程退出,这是 MyApp.vshost.exe 存在的最后一行,带有 -1 代码,但它没有达到我的应用程序的退出点。跨度>

标签: c# .net visual-studio visual-studio-2013


【解决方案1】:

我在事件日志中找到了以下事件。然而,在事件查看器 -> 自定义视图 -> 管理事件之前,这是我从未见过的一个奇怪的地方。这将我引向 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:\MyApp\MyApp\bin\Debug\MyApp.exe
Faulting module path: C:\Windows\syswow64\KERNELBASE.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:\code\MyApp\MyApp\bin\Debug\MyApp.exe</Data>
    <Data>C:\Windows\syswow64\KERNELBASE.dll</Data>
    <Data>a0b3e605-82a5-11e3-ab71-0021cc6f2033</Data>
  </EventData>
</Event>

【讨论】:

    【解决方案2】:

    我遇到了同样的问题,它看起来是一个 .net 未记录的问题。 但是你可以通过以下方式缓解它:

    • 找到失败的代码部分,然后按照您尝试阅读的课程进行操作。
    • 为该类添加一个默认构造函数。在某些情况下,序列化需要一个默认构造函数来创建对象,这就是实际问题。

    希望这适用于将搜索此错误的后代! :)

    D

    【讨论】:

      猜你喜欢
      • 2021-04-16
      • 1970-01-01
      • 1970-01-01
      • 2017-06-05
      • 2022-06-29
      • 2012-07-20
      • 2018-08-10
      • 2023-02-14
      • 1970-01-01
      相关资源
      最近更新 更多