我有一个带有控制台应用程序输出类型的项目,有时在我调试时无法启动。发生这种情况时,应用程序可能会开始运行并写入托管正在调试的进程的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 \装配\ 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 \装配\ 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 \装配\ 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 \装配\ 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的)。
答案 0 :(得分:3)
我在事件日志中找到了以下事件。然而,它是在一个奇怪的地方,我从未在事件查看器之前看过 - >自定义视图 - >行政事件。这导致我转到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>
答案 1 :(得分:0)
我遇到了同样的问题,它看起来像.net未记录的问题。 但是你可以按照以下方式缓解它:
希望这适用于将会搜索此错误的后代! :)
d