2011-05-24 51 views
2

我支持一個Silverlight 4.0的應用程序,這使得一個WCF服務的調用。當我調試服務,在IIS上本地託管時,它使它成爲此方法,但顯然使方法不會從最終返回。我沒有看到任何異常被調用。我的WCF服務的調用堆棧操作被調用,但沒有完成

這是一個商業類,它差一點就返回到調用方法的方法。

public string ExecuteMyPortalNonQuery(string CommandConfig, params object[] commandParams) 
    { 
     MyCompany.MyPortal.DataAccess.SQLDataAccess objSQLDatAcces = new SQLDataAccess(); 
     objSQLDatAcces.connection = ConfigurationSettings.AppSettings["MyPortalSQLConnection"]; 

     string SqlQueryString = ConfigurationSettings.AppSettings[CommandConfig]; 
     if (commandParams != null && commandParams.Length > 0) 
      SqlQueryString = string.Format(SqlQueryString, commandParams); 
     objSQLDatAcces.executeNonQuery(SqlQueryString); 
     return ("SUCCESS"); 
    } 

編輯

這是通過合同操作

[OperationContract] 
public string UpdateBlahblahList(int Id, int HierarchyId, int PagetypeId, string Name, string Asset, Boolean Default, string ServerName = "", string ServerConnectionString = "") 
     { 
      MyCompany.MyPortal.DataAccess.SAPAccess sp = new SAPAccess(); 
      if (Id != 0) 
       return (sp.ExecuteMyPortalNonQuery("UpdateBlahblahList", Id, Name, Asset, (Default == true) ? 1 : 0, ServerName, ServerConnectionString)); 
      else 
       return (sp.ExecuteMyPortalNonQuery("InsertBlahblahList", HierarchyId, PagetypeId, Name, Asset, (Default == true) ? 1 : 0, ServerName, ServerConnectionString)); 
     } 

也就是說,在調試時,我發現自己在正確的UpdateBlahblahCompleted方法調用客戶端跨過後叫字符串格式化線,SqlQueryString = string.Format(SqlQueryString, commandParams);

線條永遠不會到達0和return ("SUCCESS");

綜上所述:

  1. 客戶端調用UpdateBlahblahListAsync
  2. 在達到[OperationContract的] UpdateBlahblahList UpdateBlahblahList調用ExecuteMyPortalNonQuery但沒有完成
  3. 客戶端與client_UpdateBlahblahListCompleted重新進入
  4. 服務方法的服務|

的淨效應是數據庫沒有更新。

正在調試造成這種情況嗎?我與2010年

VS的兩個實例調試可以拋出異常,我還沒有發現?

編輯

感謝Simon,我知道在哪裏可以看到異常。在客戶端的異步完成方法中,參數是最內層的異常消息:「遠程服務器返回錯誤:NotFound。」。

這裏是兩個參數的值: UPDATE [dbo]。[BlahblahXref] SET [PageId] ='{1}',[Name] ='{2}',[Asset] ='{3 }」,[默認] = '{4}',[服務器] = '{5}',[ServerConnectionString] = '{6}' 其中id = {0}

commandParams [] = {375,「測試」,「111」,0,「someServerName」,「一些長期連接字符串」}

+1

client_UpdateBlahblahListCompleted args中是否有錯誤? – 2011-05-24 18:48:39

+0

這就是我應該看的地方。是。 ** System.Reflection.TargetInvocationException **和內部異常** ** System.Net.WebException:遠程服務器返回一個錯誤:NotFound。 at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse ** – Blanthor 2011-05-24 18:59:15

+1

在服務器上發生了一些異常,您在客戶端看到的主要是它的後果。嘗試在服務器端啓用跟蹤 - http://msdn.microsoft.com/en-us/library/ms733025.aspx - 和/或使用網絡跟蹤工具(如Fiddler)查看服務器對客戶端的響應。有了這些信息,我們可以幫助您更多。 – carlosfigueira 2011-05-24 19:26:16

回答

0

在你的託管應用程序(Web或控制檯,等等)的配置文件,你可以把下面幾行啓用跟蹤記錄:

<system.diagnostics> 
    <sources> 
     <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true"> 
      <listeners> 
       <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="Services.svclog" /> 
      </listeners> 
     </source> 
    </sources> 
</system.diagnostics> 

然後再次重現您的錯誤,打開「Services.svclog」,您將能夠看到wcf調用的詳細信息,包括異常詳細信息。