2013-08-01 100 views
1

我做了一個Silverlight應用程序WCF RIA服務,它有一個登錄頁面,用於驗證數據庫中的用戶名和密碼......當我從VS2010進行調試時它工作得很好,但是當我發佈到IIS7時, 「T與數據庫連接任何更多...我已經在Web.config所做的所有的設置...我已經添加了clientaccesspolicy.xml和crossdomain.xml檔案我的項目...添加MIME類型與IIS7沒有結果......我發現一個錯誤與IE9的開發工具和它說:IIS7主機Silverlight應用程序

SCRIPT5022: Unhandled Error in Silverlight Application An exception occurred during the operation, making the result invalid. Check InnerException for exception details. at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary() 
    at MaG.ServiceReference1.LoginCompletedEventArgs.get_Result() 
    at MaG.MainPage.connection_LoginCompleted(Object sender, LoginCompletedEventArgs e) 
    at MaG.ServiceReference1.Service1Client.OnLoginCompleted(Object state) 
MaGTestPage.html, line 1 character 1 

我呼籲登錄法客戶端的WebService是這樣的:

try 
    { 
     ServiceReference1.Service1Client connection = new ServiceReference1.Service1Client();    
     connection.LoginCompleted += new EventHandler<ServiceReference1.LoginCompletedEventArgs>(connection_LoginCompleted); 
     connection.LoginAsync(textBox1.Text, passwordBox1.Password); 
    } 
     catch (Exception ex) 
    { 
     Console.Write(ex.InnerException); 
    } 

回答

0

這樣做的原因將在你的事件處理程序,connection_LoginCompleted被發現。使用此方法來檢查,第一,任何服務錯誤:如果您嘗試訪問e.Result時出現錯誤

void connection_LoginCompleted(object sender, LoginCompletedEventArgs e) 
{ 
    if (e.Error != null) 
    { 
     MessageBox.Show(e.Error.ToString()); 
    } 
    else 
    { 
     // handle result 
    } 
} 

,對象將拋出你看到的例外。

+0

謝謝你非常非常......你救了我......上帝與你同在 –