【问题标题】:IIS7 Hosting Silverlight ApplicationIIS7 托管 Silverlight 应用程序
【发布时间】:2013-08-01 18:59:56
【问题描述】:

我制作了一个 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 方法客户端上诉到 web 服务,如下所示:

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

【问题讨论】:

    标签: wcf silverlight iis-7 hosting publish


    【解决方案1】:

    原因将在您的事件处理程序connection_LoginCompleted 中找到。使用这种方法首先检查任何服务错误:

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

    如果你在出错时尝试访问e.Result,对象会抛出你看到的异常。

    【讨论】:

    • 非常感谢...你救了我...上帝与你同在
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多