Wednesday, December 03, 2008 2:36 PM
In my solution, there are 3 projects: Sliverlight project1, web project2, WCF project3.
Create WCF service in project3. Add service reference in project 1 and call the service in a test xaml control. Then run the testing page in project2. I got error.
The error message is:
throw new Error("Unhandled Error in Silverlight 2 Application An exception occurred during the operation, making the result invalid. Check InnerException for exception details. at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()\n at SLUI.ServiceReference1.TestCompletedEventArgs.get_Result()\n at SLUI.ServiceTest.proxy_TestCompleted(Object sender, TestCompletedEventArgs e)\n at SLUI.ServiceReference1.Services1Client.OnTestCompleted(Object state)");
But If I create same service in project2, and add service reference in project1, it works fine. So looks like separate service application doesn't work for sliverlight control.
So question is:
WCF Services/Web Service must be hosted on the same web application to host the siliverlight application?
Here is the simplest code for the demo:
public string Test()
return "Hello, Test string here.";
xaml code behind:
public partial class ServiceTest : UserControl
Loaded += new RoutedEventHandler(ServiceTest_Loaded);
void ServiceTest_Loaded(object sender, RoutedEventArgs e)
ServiceReference1.Services1Client proxy= new SLUI.ServiceReference1.Services1Client();
proxy.TestCompleted += new EventHandler<SLUI.ServiceReference1.TestCompletedEventArgs>(proxy_TestCompleted);
void proxy_TestCompleted(object sender, SLUI.ServiceReference1.TestCompletedEventArgs e)
myString.Text = e.Result;
Wednesday, December 03, 2008 2:53 PM
No the web service does not need to be hosted by the same web that the Silverlight(SL) app list is hosted. In order for this to work in SL, you'll have to have the appropriate clientaccesspolicy.xml or crossdomain.xml in the root of the remote web host application, to allow the cross-domain access.
Wednesday, December 03, 2008 3:43 PM
thank you very much. It works fine now.
Monday, February 16, 2009 2:33 AM
What does one do, however, if the WCF service is self-hosted in a Windows Service, with that portion of the HTTP namespace upon which it listens reserved via 'netsh' on Windows Vista or 'httpCfgAcl' on WS 2003? When not hosted in IIS, what placement of the client access file is required?