RIA Service Error in a Silverlight Application

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"?>

<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>

Open in new window


The Code for my RiaService Class looks 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 MyRiaService : 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();
        }


    }
}

Open in new window

LVL 1
FaheemAhmadGulAsked:
Who is Participating?
 
Kyle AbrahamsSenior .Net DeveloperCommented:
After going live the solution was the .svc file wasn't being served.
To fix this add this to the webserver section:
      <add name=".svc" verb="*" path="*.svc" type="System.ServiceModel.Activation.ServiceHttpHandlerFactory, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </handlers>

Open in new window


below is the full web.config used for reference.
<configuration>
  
    <system.web>
      <compilation debug="true" targetFramework="4.6" />
      <httpRuntime targetFramework="4.6" />
      <httpModules>
        <add name="DomainServiceModule"  type="System.Web.Ria.Services.DomainServiceHttpModule, System.Web.Ria" />
      </httpModules>
    </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>
    <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>
  </system.webServer>


 

</configuration>

Open in new window

0
 
Kyle AbrahamsSenior .Net DeveloperCommented:
How do you have the reference setup on the Silverlight side?

The error is pointing to "not found".  The best way to do this is to hit the service in a web browser and make sure it's deployed correctly.  From there I would add the url of the service that worked in the browser and then try it from there.
0
 
FaheemAhmadGulAuthor Commented:
Many thanks. I am very grateful.

Regards
Faheem
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.