title: Silverlight can't talk to RIA service
body: <p>I've followed the tutorial here: <a href="http://www.silverlight.net/learn/tutorials/sqldatagrid-cs/" rel="nofollow noreferrer">http://www.silverlight.net/learn/tutorials/sqldatagrid-cs/</a></p>
  
  <hr>
  
  <p><strong>ANSWER</strong>: 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 <em>assume</em>, don't we... </p>
  
  <p>Bottom line: Right-click service project in Solution Explorer, Properties | Web | Specific Port</p>
  
  <hr>
  
  <p>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).</p>
  
  <p>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</p>
  
  <p>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? </p>
  
  <blockquote>
    <p>e._error {System.ServiceModel.CommunicationException: An error
    occurred while trying to make a request to URI
    <code>'http://localhost:15459/Service1.svc'</code>. 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.&lt;>c__DisplayClass5.b__4(Object
    sendState)    at
    System.Net.Browser.AsyncHelper.&lt;>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.ClientBase<code>1.ChannelBase</code>1.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}</p>
  </blockquote>