简体   繁体   中英

IIS7 Hosting Silverlight Application

I have made a Silverlight Application WCF RIA Services which have's a login page that verify the username and password in a database ... it has worked perfectly when I debug from VS2010 but when I publish to IIS7 it doesn't connect with database any more ... I've made all the settings in the Web.config ... I've added the clientaccesspolicy.xml and crossdomain.xml to my project ... added the MIME types to IIS7 with no result ... I find an error with development tools from IE9 and it says :

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

I appeal the Login method client to webservice like this:

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

The reason for this will be found in your event handler, connection_LoginCompleted . Use this approach to check, first, for any service error:

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

If you try to access e.Result when there is an error, the object will throw the exception you see.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM