2010-11-03 74 views
1

我有一個WCF數據服務託管在Asp.Net網站。這裏是我的web.config服務部分:如何調試WCF數據服務?

<system.serviceModel> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> 
<services> 
    <service name="DataServiceHost" 
    behaviorConfiguration="DataServiceBehavior"> 
    <endpoint name="DataServiceHost" 
        address="" 
        binding="webHttpBinding" 
        contract="System.Data.Services.IRequestHandler" /> 
      </service> 
</services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="DataServiceBehavior"> 
     <serviceDebug includeExceptionDetailInFaults="true"/> 
    </behavior> 

而且我在InitializeService方法config.UseVerboseErrors = true;

我打了F5我進入調試模式,並瀏覽到我的服務,得到一個錯誤,雖然它沒有在VS中打破。我很茫然。

錯誤btw:服務器在處理請求時遇到錯誤。查看服務器日誌獲取更多詳細信

我查找了日誌...我有ELMAH設置爲該網站,沒有在那裏。所以我不確定它在說什麼服務日誌

任何幫助將不勝感激。

+0

你是如何「瀏覽到你的服務」? – 2010-11-03 16:17:03

+0

http://localhost/services/myservice.svc我有調試安裝程序使用IIS。 – 2010-11-03 16:24:04

回答

1

您可以啓用錯誤日誌記錄是這樣的:

<system.diagnostics> 
    <sources> 
     <source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing"> 
     <listeners> 
      <add type="System.Diagnostics.DefaultTraceListener" name="Default"> 
      <filter type="" /> 
      </add> 
      <add name="ServiceModelMessageLoggingListener"> 
      <filter type="" /> 
      </add> 
     </listeners> 
     </source> 
    </sources> 
    <sharedListeners> 
     <add initializeData="c:\TEMP\web_messages.svclog" 
     type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
     name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp"> 
     <filter type="" /> 
     </add> 
    </sharedListeners> 
    </system.diagnostics> 

含硒較多的信息在這裏:http://msdn.microsoft.com/en-us/library/ms730064.aspx

輸出文件可以在notedpad或「服務跟蹤查看器」中查看 - 看http://msdn.microsoft.com/en-us/library/aa751795.aspx

如果你在IIS中主機,你可以使用遠程調試:http://www.codeproject.com/KB/aspnet/IISRemoteDebugging.aspx

+0

那麼...有沒有辦法調試我的本地機器上運行的東西?託管在我的本地機器上的一個網站上,用VS調試器 - >附加到過程方法? – 2010-11-03 20:12:26

+0

如果它是從VS啓動的,它已經處於調試模式,您應該能夠正常插入斷點。 如果它在VS外運行,如果您正在運行調試版本,則可以使用attach進程。 – Fedearne 2010-11-03 20:40:20

+1

問題是,我相信它會在反映服務的元數據時拋出錯誤,可能是因爲我在某處丟失了某個屬性。我已經嘗試覆蓋'Handle Exception'並在其中粘貼'Debugger.Break();',但它永遠不會被擊中。 – 2010-11-05 14:19:52