C# 计划';[13476]MyApp.vshost.exe';已退出,代码为-1(0xffffffff)

C# 计划';[13476]MyApp.vshost.exe';已退出,代码为-1(0xffffffff),c#,.net,visual-studio,visual-studio-2013,C#,.net,Visual Studio,Visual Studio 2013,我有一个输出类型为控制台应用程序的项目,在调试时有时无法启动。发生这种情况时,may应用程序将开始运行并写入正在调试的进程所在的vshost.exe控制台。然后突然,我会在输出窗口中看到一条消息,上面写着“程序'[13476]MyApp.vshost.exe'已退出,代码为-1(0xFFFFFF)。” 这种情况并非每次都会发生,但当它出现在控制台窗口时,我的应用程序会在屏幕上冻结启动,调试器似乎会停止。但是,vshost.exe进程实际上并没有停止(我可以在任务管理器中看到它,其进程ID与错误消

我有一个输出类型为控制台应用程序的项目,在调试时有时无法启动。发生这种情况时,may应用程序将开始运行并写入正在调试的进程所在的vshost.exe控制台。然后突然,我会在输出窗口中看到一条消息,上面写着“程序'[13476]MyApp.vshost.exe'已退出,代码为-1(0xFFFFFF)。”

这种情况并非每次都会发生,但当它出现在控制台窗口时,我的应用程序会在屏幕上冻结启动,调试器似乎会停止。但是,vshost.exe进程实际上并没有停止(我可以在任务管理器中看到它,其进程ID与错误消息相同)。就好像VisualStudio认为该进程已经退出,但实际上并没有。当我停止调试器时,控制台窗口在屏幕上也保持冻结状态。让调试器再次工作的唯一方法是关闭并重新启动VS

如果我关闭了VisualStudio宿主进程,也会发生这种情况。应用程序在Main方法中只有一个出口点,当这种情况发生时,该代码行上的断点不会被命中

我不知道如何获得更多关于为什么会发生这种情况的详细信息来进一步排除故障。我已将代码放入AppDomain.CurrentDomain.UnhandledException处理程序以及Application.ApplicationExit处理程序中,但当出现此问题时,它们不会受到影响。我在Windows事件日志等中也没有看到任何内容

输出窗口示例

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

“MyApp.vshost.exe”(CLR v4.0.30319:MyApp.vshost.exe):已加载 “C:\Windows\Microsoft.Net\assembly\GAC\U MSIL\System.ServiceModel.Web\v4.0.0.0\UUU 31bf3856ad364e35\System.ServiceModel.Web.dll”。 找不到或无法打开PDB文件

“MyApp.vshost.exe”(CLR v4.0.30319:MyApp.vshost.exe):已加载 “C:\Windows\Microsoft.Net\assembly\GAC\U MSIL\Microsoft.VisualStudio.Diagnostics.ServiceModelSink\v4.0\U 4.0.0.0\Uuu 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.0.0_uuB03F5F7F11D50A3A\System.Net.Http.dll'。 已跳过加载符号。模块已优化,调试器选项 “仅我的代码”已启用

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

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

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

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


我在事件日志中找到了下面的事件。然而,它位于一个奇怪的位置,我以前从未看过事件查看器->自定义视图->管理事件。这让我找到了MS KB

MyApp项目的目标是.NET 4.0,我最近在我的笔记本电脑(.NET 4.5)上安装了Visual Studio 2013,大约在问题开始出现的时候。所以我想这是我的问题

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>
我不明白的是,为什么这个异常没有引发MyApp项目中的AppDomain.UnhandledException事件,而是以静默方式终止进程。导致此问题的WCF服务是从正在启动的新线程启动的,但我认为此线程中的异常仍应引发AppDomain.UnhandledException事件。我验证了UndhandledException处理程序是否在我的应用程序中工作

为了解决这个问题,我将这个服务的启动转移到了它自己的项目中,该项目的目标是.NET3.5和x86。这更像是我们在生产环境中运行应用程序的方式,所以它对我来说很有用。Microsoft知识库中也有一个补丁和各种解决方法

我希望这对某人有所帮助,我当时正拼命想弄清楚如何获得导致我的问题的异常

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>
日志名称:应用程序
源:.NET运行时
日期:2014年1月21日上午9:09:23
事件ID:1026
任务类别:无
级别:错误
关键词:经典
用户:不适用
计算机:杜德尔特
说明:
应用程序:MyApp.exe
框架版本:v4.0.30319
描述:由于未处理的异常,进程已终止。
异常信息:System.ServiceModel.AddressalReadyUseException
堆栈:
位于System.ServiceModel.Channels.TransportManager.Open(System.ServiceModel.Channels.TransportChannelListener)
在System.ServiceModel.Channels.TransportManagerContainer.Open(System.ServiceModel.Channels.SelectTransportManagerCallback)中打开
位于System.ServiceModel.Channels.TransportChannelListener.OnOpen(System.TimeSpan)
位于System.ServiceModel.Channels.ConnectionOrientedTransportChannelListener.OnOpen(System.TimeSpan)
在System.ServiceModel.Channels.TcpChannelListener`2[[System.\uu Canon,mscorlib,Version=4.0.0.0,Culture=中性,PublicKeyToken=b77a5c561934e089],[System.\uu Canon,mscorlib,Version=4.0.0,Culture=中性,PublicKeyToken=b77a5c561934e089]。OnOpen(System.TimeSpan)
打开System.ServiceModel.Channels.CommunicationObject.Open(System.TimeSpan)
在System.ServiceModel.Channels.ReliableChannelListenerBase`1[[System.\uu Canon,mscorlib,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089].OnOpen(System.TimeSpan)
打开System.ServiceModel.Channels.CommunicationObject.Open(System.TimeSpan)
位于System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(System.TimeSpan)
打开System.ServiceModel.Channels.CommunicationObject.Open(System.TimeSpan)
位于System.ServiceModel.ServiceHostBase.OnOpen(System.TimeSpan)
在System.ServiceModel.Channels.CommunicationObject.Open(System。