Note that there are some explanatory texts on larger screens.

plurals
  1. POSimple WCF Webservice Call from Silverlight (Need Help Please!)
    text
    copied!<p>I'm new to Silverlight programming and networking in general and I've been trying to find an answer to this all day. I'm trying to build a very simple Silverlight4 web application in VS2010 that calls a webservice on the ASP.NET website (exact same Solution as the Silverlight client app so there shouldn't be any cross-domain issues???). I wrote a Webservice using VS' "Silverlight-Enabled WCF Service" that simply returns a string.</p> <p>I then wrote the code to consume the service in Silverlight:</p> <p>public MainPage() { InitializeComponent();</p> <pre><code> TestServiceClient proxy = new TestServiceClient(); EndpointAddress address = new EndpointAddress("http://localhost:" + HtmlPage.Document.DocumentUri.Port + "/SilverlightApplication1.web/TestService.svc"); proxy.Endpoint.Address = address; proxy.GetStringCompleted += new EventHandler&lt;GetStringCompletedEventArgs&gt;(proxy_GetStringCompleted); proxy.GetStringAsync(); } void proxy_GetStringCompleted(object sender, GetStringCompletedEventArgs e) { MessageBox.Show(e.Result.ToString()); } </code></pre> <p>This works great when I run it from VS2010. However, when I publish it to my personal webserver (IIS7) on the same computer, I get an error:</p> <p>Webpage error details</p> <p>User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; .NET4.0C; .NET4.0E) Timestamp: Mon, 17 May 2010 08:29:51 UTC</p> <p>Message: 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 SilverlightApplication1.TestServiceReference1.GetStringCompletedEventArgs.get_Result() at SilverlightApplication1.MainPage.proxy_GetStringCompleted(Object sender, GetStringCompletedEventArgs e) at SilverlightApplication1.TestServiceReference1.TestServiceClient.OnGetStringCompleted(Object state) Line: 1 Char: 1 Code: 0 URI: <a href="http://thunder.webhop.org:8001/home.html" rel="nofollow noreferrer">http://thunder.webhop.org:8001/home.html</a></p> <p>When I catch the exception in App.xaml.cs, I get the following message:</p> <p>System.InvalidOperationException: Eval failed. at System.Windows.Browser.HtmlWindow.Eval (String code) at SilverlightApplication1.App.ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e)</p> <p>I should mention that the webserver otherwise seems to work fine. I can host Silverlight apps on it without any problems through port 8001. I just can't for the life of me figure out how to make a successful webservice call! Any help with this would be GREATLY appreciated. I've wasted an entire afternoon and evening on this. My mind's flipping in circles right now... :-(</p> <p>Many, many thanks in advance! Luck</p> <p>P.S. Apologies for cross-posting at Silverlight forums but had some problems there while posting.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload