IIS7托管Silverlight应用程序

时间:2013-08-01 18:59:56

标签: wcf silverlight iis-7 hosting publish

我已经制作了一个Silverlight应用程序WCF RIA服务,它有一个登录页面,用于验证数据库中的用户名和密码...当我从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

我将Login方法客户端上诉到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);
   }

1 个答案:

答案 0 :(得分:0)

可以在事件处理程序connection_LoginCompleted中找到原因。首先,使用此方法检查是否存在任何服务错误:

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

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