Wcf IIS7托管Silverlight应用程序

Wcf IIS7托管Silverlight应用程序,wcf,silverlight,iis-7,hosting,publish,Wcf,Silverlight,Iis 7,Hosting,Publish,我制作了一个Silverlight应用程序WCF RIA Services,它有一个登录页面,用于验证数据库中的用户名和密码。。。当我从VS2010调试时,它工作得非常好,但当我发布到IIS7时,它不再与数据库连接。。。我已经在Web.config中进行了所有设置。。。我已将clientaccesspolicy.xml和crossdomain.xml添加到我的项目中。。。已将MIME类型添加到IIS7,但没有结果。。。我发现IE9中的开发工具有一个错误,它说: SCRIPT5022: Unhan

我制作了一个Silverlight应用程序WCF RIA Services,它有一个登录页面,用于验证数据库中的用户名和密码。。。当我从VS2010调试时,它工作得非常好,但当我发布到IIS7时,它不再与数据库连接。。。我已经在Web.config中进行了所有设置。。。我已将clientaccesspolicy.xml和crossdomain.xml添加到我的项目中。。。已将MIME类型添加到IIS7,但没有结果。。。我发现IE9中的开发工具有一个错误,它说:

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);
   }

原因将在事件处理程序connection\u Login Completed中找到。使用此方法首先检查是否存在任何服务错误:

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

如果您在出现错误时尝试访问e.Result,对象将抛出您看到的异常。

非常感谢您。。。你救了我。。。愿上帝与你同在