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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
FaheemAhmadGulAuthor Commented:
Many thanks. I am very grateful.

Regards
Faheem
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.