将JSON端点添加到WCF Silverlight RIA服务后出错

时间:2012-08-24 22:41:03

标签: json silverlight wcf-ria-services

我正在尝试使用此处的信息将json端点添加到现有的WCF RIA Silverlight服务:

http://blogs.msdn.com/b/deepm/archive/2010/05/14/silverlight-tv-episode-26-exposing-soap-json-and-odata-endpoints-from-ria-services.aspx

然而,当我在调试中启动项目时,我得到了一个

  

远程服务器返回错误:NotFound。

Silverlight中的

错误。

WCF Trace说:

  

System.ServiceModel.ServiceActivationException:该服务   '/Services/CTCT-KronosNameManagement-Web-Services-BPAuthenticationDomainService.svc'   由于编译期间的异常,无法激活。该   异常消息是:无法加载文件或程序集   'Microsoft.ServiceModel.DomainServices.Hosting,Version = 4.0.0.0,   Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其中一个   依赖。系统找不到指定的文件.. ---& gt;   System.IO.FileNotFoundException:无法加载文件或程序集   'Microsoft.ServiceModel.DomainServices.Hosting,Version = 4.0.0.0,   Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其中一个   依赖。该系统找不到指定的文件。在   System.RuntimeTypeHandle.GetTypeByName(String name,Boolean   throwOnError,Boolean ignoreCase,Boolean reflectionOnly,   StackCrawlMarkHandle stackMark,IntPtr pPrivHostBinder,Boolean   loadTypeFromPartialName,ObjectHandleOnStack type)at   System.RuntimeTypeHandle.GetTypeByName(String name,Boolean   throwOnError,Boolean ignoreCase,Boolean reflectionOnly,   StackCrawlMark和放大器;放大器; stackMark,IntPtr pPrivHostBinder,Boolean   System.RuntimeType.GetType(String。的loadTypeFromPartialName)   typeName,Boolean throwOnError,Boolean ignoreCase,Boolean   reflectionOnly,StackCrawlMark& amp; stackMark)at   System.Type.GetType(String typeName,Boolean throwOnError)at   System.ServiceModel.DomainServices.Hosting.DomainServiceHost.CreateEndpointFactoryInstance(ProviderSettings   提供者)   System.ServiceModel.DomainServices.Hosting.DomainServiceHost.CreateDescription(IDictionary`2&放大器;放大器;   已实施的合同   System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection   baseAddresses)at   System.ServiceModel.ServiceHost.InitializeDescription(类型   serviceType,UriSchemeKeyedCollection baseAddresses)at   System.ServiceModel.DomainServices.Hosting.DomainServiceHost..ctor(类型   domainServiceType,Uri [] baseAddresses)at   System.ServiceModel.DomainServices.Hosting.DomainServiceHostFactory.CreateServiceHost(类型   serviceType,Uri [] baseAddresses)at   System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(字符串   constructorString,Uri [] baseAddresses)at   System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(字符串   normalizedVirtualPath,EventTraceActivity eventTraceActivity)at   System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(ServiceActivationInfo   serviceActivationInfo,EventTraceActivity eventTraceActivity)at   System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(字符串   normalizedVirtualPath,EventTraceActivity eventTraceActivity)---   内部异常堆栈跟踪结束---

如果我删除了网络配置中的端点,那么繁荣:它再次有效......当然除了json之外。

 <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <domainServices>
      <endpoints>
        <add name="JSON" type="Microsoft.ServiceModel.DomainServices.Hosting.JsonEndpointFactory, Microsoft.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </endpoints>
    </domainServices>
</system.serviceModel>

我确实安装了WCF Ria Services Toolkit。 System.ServiceModel.DomainServices.Hosting.dll版本为4.1.61829.0

任何建议都会非常有用。

1 个答案:

答案 0 :(得分:0)

尽管Deepesh明确表示你需要在写作中添加对Microsoft.ServiceModel.DomainServices.Hosting.dll的引用,但我认为视频中没有提到这一点,当我进行故障排除时,我看到我提到了System.ServiceModel.DomainServices.Hosting.dll并没有注意到两个DLL之间存在差异。添加对第一个修复所有内容的引用。