2014-01-17 55 views
1

我有一个项目,输出类型为控制台应用程序,有时在调试时无法启动。发生这种情况时,应用程序可能会开始运行并写入托管正在调试的进程的vshost.exe控制台。然后突然间,我会在输出窗口中看到一条消息,上面写着“The program'[13476] MyApp.vshost.exe'已退出,代码为-1(0xffffffff)。”程序'[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):Loaded '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 \组件\ 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):Loaded 'C:\ Windows \ Microsoft.Net \ assembly \ GAC_MSIL \ System.Net.Http \ v4.0_4。 0.0.0__b03f5f7f11d50a3a \ System.Net.Http.dll”。 跳过加载符号。模块已经过优化,调试器选项 “Just My Code”已启用。

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

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

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

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

+0

你所描述的对于VS2013来说都是正常的,我也看到了这些退出代码以及完美正常执行的程序。 vshost.exe不能退出是正常的。只要尝试一个无所事事的新控制台模式项目。这不会让人猜测你的程序为什么行为不当。 –

+0

我并不担心线程退出,它是MyApp.vshost.exe存在的最后一行,带有-1代码,但它不会触及我的应用程序的退出点。 – Dude0001

回答

2

我发现下面的事件日志中的事件。然而,这是一个奇怪的地方,我从来没有看过之前事件查看器 - >自定义视图 - >管理事件。这导致我的MS KB http://support.microsoft.com/kb/2773443

MyApp项目的目标是.NET 4.0和我最近安装了Visual Studio 2013在我的笔记本电脑(.NET 4.5),这是解决这个问题开始发生的时间。所以我认为这是我的问题。

我不明白的是为什么这个异常是不是在我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> 
0

我遇到了同样的问题,它看起来是.net未公开的问题。 可以减轻它如下:

  • 发现,失败的部分代码,并按照您尝试读取这个类。
  • 为该类添加默认构造函数。序列化在某些情况下需要一个默认构造函数来创建对象,这是实际的问题。

希望这个作品,为子孙后代谁将会为这个错误搜索! :)

D