2011-01-28 39 views
0

我有一個WCF Web服務(使用.NET 3.5),我試圖調試。但是,每當我在程序中設置任何斷點時,它們在調試模式下運行時都不會被命中。此外,Visual Studio不會捕獲任何異常 - 通常,當調試時拋出未捕獲的異常時,Visual Studio將顯示拋出的異常並將您引導至拋出異常的代碼行。Visual Studio 2010調試器沒有爲WCF項目做任何事

任何人都可以解釋一下這個問題?

+0

是否加載了符號? PDB文件..... – Gabe 2011-01-28 22:28:52

+0

調試時,您的中斷點是紅色點還是紅色的中心點? – 2011-01-28 22:33:50

回答

0

您是否試圖遠程調試服務?在這種情況下,您還需要在遠程計算機上運行VS Remote Debugger。你

還應設置服務調試行爲在你的代碼來獲得異常的詳細信息,如:

ServiceHost MyServiceHost = new ServiceHost(myService, myBaseAddress); 

#if CONFIG = "Debug" 
//set Service Debug Behavior (for security should not be enabled during deployment) 
Description.ServiceDebugBehavior sdb = MyServiceHost.Description.Behaviors.Find<Description.ServiceDebugBehavior>(); 
if (sdb == null) { 
sdb = new Description.ServiceDebugBehavior(); 
MyServiceHost.Description.Behaviors.Add(sdb); 
} 
sdb.IncludeExceptionDetailInFaults = true; 
#endif 

MyServiceHost.AddServiceEndpoint(typeof(IMyService), new NetTcpBinding(), myBaseAddress); 
MyServiceHost.Open(); 
0

我很晚這個答案,但也許它會幫助別人。當您調試使用本地IIS而不是Visual Studio開發服務器的Web服務時,您可能會遇到此問題。

在這種情況下,您必須附加到IIS的運行實例,而不只是點擊「運行」。要做到這一點,點擊Debug => Attach To Process。然後,選擇進程,「w3wp.exe」。最後,選擇「附加」,你應該全部設置。

enter image description here