【发布时间】:2018-02-18 17:39:51
【问题描述】:
在一个非常简单的 Silverlight 应用程序中,我有一个 DomainService 类,它有一个返回字母对象列表的方法。
当我在 VisualStudio 中运行该应用程序时,它运行良好。但是,当我将它发布到我的 Windows 10 本地计算机上的文件夹并使用 IIS(版本 10.0.166299.5)运行它时,我收到以下错误:
远程服务器返回错误:NotFound。 在 System.ServiceModel.DomainServices.Client.OperationBase.Complete(Exception error) 在 System.ServiceModel.DomainServices.Client.LoadOperation.Complete(Exception error) 在 System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult) 在 System .ServiceModel.DomainServices.Client.DomainContext.c__DisplayClass1b.b__17(Object )
我怀疑这是因为我的 WebConfig 文件中缺少某些错误。 我的 WebConfig 目前如下所示:
<?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>
我的域服务类的代码是这样的:
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();
}
}
}
【问题讨论】:
标签: silverlight web-config wcf-ria-services