views:

124

answers:

2

I've followed the tutorial here: http://www.silverlight.net/learn/tutorials/sqldatagrid-cs/


ANSWER: When I ran this thing in the debugger, it was starting it up on port 16048. Meanwhile, ServiceReferences.ClientConfig had the endpoint address using port 15459. No clue why it did that, but once I changed it so it was accessing the service on port 16048, it was fine. I had noticed that the ports differed, but had assumed that it was using a different port for the service for some sane reason. And we all know who we make an ass out of when we assume, don't we...


In the tutorial, you create a simple Silverlight XAP thing, create an RIA service in the same solution, and call the service from Silverlight. I've been running it in VS2010 with the built-in web server. When the async call to the service completes, the result's _error is set to System.ServiceModel.CommunicationException (see below).

I cannot over-stress the fact that the service and the Silverlight app are both on the same machine, the same physical computer sitting on my desk. I've added crossdomain.xml and clientaccesspolicy.xml

The tutorial is from 2008, and seems to be obsolete in some respects. The RIA thing seems handy, but does Silverlight simply not support it? Has MS abandoned WCF and/or RIA for something else already? Is there some other new way to get data from a server to Silverlight? What's a Domain Service? Is that better? Is it the last big thing or the next? How does anybody keep track?

e.error {System.ServiceModel.CommunicationException: An error occurred while trying to make a request to URI 'http://localhost:15459/Service1.svc'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details. ---> System.Security.SecurityException ---> System.Security.SecurityException: Security error. at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) at System.Net.Browser.BrowserHttpWebRequest.<>c_DisplayClass5.b_4(Object sendState) at System.Net.Browser.AsyncHelper.<>c_DisplayClass2.b__0(Object sendState) --- End of inner exception stack trace --- at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state) at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result) --- End of inner exception stack trace --- at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result) at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result) at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result) at System.ServiceModel.ClientBase1.ChannelBase1.EndInvoke(String methodName, Object[] args, IAsyncResult result) at SilverlightApplication1.ServiceReference1.Service1Client.Service1ClientChannel.EndGetITEM_THINGs(IAsyncResult result) at SilverlightApplication1.ServiceReference1.Service1Client.SilverlightApplication1.ServiceReference1.IService1.EndGetITEM_THINGs(IAsyncResult result) at SilverlightApplication1.ServiceReference1.Service1Client.OnEndGetITEM_THINGs(IAsyncResult result) at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)} System.Exception {System.ServiceModel.CommunicationException}

A: 

I would suggest following this tutorial:

http://www.silverlight.net/learn/videos/silverlight-4-videos/ria-services-support-visual-studio-2010/

Ardman
Thanks! I'll take a look.
Ed J. Plunkett
I had a similar problem where I couldn't get the data to work locally, but when I put it on a server it worked. That's why I used the tutorial in my answer so that I could get everything to work. Hope it helps.
Ardman
A: 

From the error message, I would guess that your clientaccesspolicy.xml file is either not in the correct location(must be in the root directory of the service) or is not configured to allow access to the service. Check out HTTP Communication and Security with Silverlight for more information about accessing services with Silverlight.

Microsoft has not abandoned WCF and/or RIA.

DaveB
Actually, it turned out I could get rid of clientaccesspolicy.xml entirely. The problem wasn't related to that stuff at all.
Ed J. Plunkett