0
votes

In a very simple Silverlight Application I have a DomainService Class which has a single method that returns a list of Letter Objects.

The application works fine when I run it in VisualStudio. However, when I publish it to a folder on my Windows 10 local machine and run it using IIS (version 10.0.166299.5) I get the following error:

The remote server returned an error: NotFound. at System.ServiceModel.DomainServices.Client.OperationBase.Complete(Exception error) at System.ServiceModel.DomainServices.Client.LoadOperation.Complete(Exception error) at System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult) at System.ServiceModel.DomainServices.Client.DomainContext.<>c__DisplayClass1b.b__17(Object )

I supect this is due to something being wrong in missing in my WebConfig file. My WebConfig Currently looks like this:

<?xml version="1.0"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>

    <system.web>
      <compilation debug="true" targetFramework="4.6" />
      <httpRuntime targetFramework="4.6" />
    </system.web>




  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true">
      <add name="DomainServiceModule" preCondition="managedHandler" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </modules>
  </system.webServer>


  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>


</configuration>

The code for my Domain Service Class is like this:

using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.DomainServices.Hosting;
using System.ServiceModel.DomainServices.Server;
using SilverData.Web.Models;

namespace SilverData.Web.Services
{
    [EnableClientAccess]
    public class DrugsRiaService : DomainService
    {


        public IQueryable<Letter> GetAllLetters()
        {
            List<Letter> letters = new List<Letter>();

            Letter letterA = new Letter { ID = 1, Statement = "Mike" };
            Letter LetterB = new Letter { ID = 2, Statement = "Emma" };
            Letter LetterC = new Letter { ID = 3, Statement = "Peter" };

            letters.Add(letterA);
            letters.Add(LetterB);
            letters.Add(LetterC);



            return letters.AsQueryable();
        }


    }
}
2

2 Answers

1
votes

The error was due to the problem that .svc file wasn't being served.. The problem got solved with the kind help from the Kyle Abraham on Experts Exchange.

https://www.experts-exchange.com/questions/29084691/RIA-Service-Error-in-a-Silverlight-Application.html

The solution was to add the following line to the webserver section of the Webconfig

<handlers>
  <add name=".svc" verb="*" path="*.svc" type="System.ServiceModel.Activation.ServiceHttpHandlerFactory, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</handlers>
0
votes

I'm not sure, its a guess as I have not used RIA for awhile, but I think letters needs to returned as something other than queryable... try ToList() which causes the query to execute, and the payload is complete with the complete enumeration that was retrieved from the database. Remember, this is a remote call from a client, not a local one that can extend the queryable.