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

我正在尝试使用此处的信息将json endpoints 添加到现有的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'或其依赖项之一 . 系统找不到指定的文件.. ---> 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, System.ServiceModel上的System.Type.GetType(String typeName,Boolean throwOnError)处的System.RuntimeType.GetType(String typeName,Boolean throwOnError,Boolean ignoreCase,Boolean reflectionOnly,StackCrawlMark& stackMark)中的StackCrawlMark& stackMark,IntPtr pPrivHostBinder,Boolean loadTypeFromPartialName)位于S的System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses)的System.ServiceModel.DomainServices.Hosting.DomainServiceHost.CreateDescription(IDictionary`2& implementedContracts)的.DomainServices.Hosting.DomainServiceHost.CreateEndpointFactoryInstance(ProviderSettings provider) System.ServiceModel.DomainServices.Hosting.DomainServiceHostFactory.CreateServiceHost上的System.ServiceModel.DomainServices.Hosting.DomainServiceHost..ctor(类型domainServiceType,Uri [] baseAddresses)中的ystem.ServiceModel.ServiceHost.InitializeDescription(类型serviceType,UriSchemeKeyedCollection baseAddresses) ServiceType,Uri [] baseAddresses)在System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString,Uri [] baseAddresses)的System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath,EventTraceActivity eventTraceActivity)处于System.ServiceModel.ServiceHostingEnvironment . System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath,EventTraceActivity eventTraceActivity)中的HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo,EventTraceActivity eventTraceActivity)---内部异常堆栈跟踪结束---

如果我在web配置中删除 endpoints ,繁荣:它再次工作......当然除了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)

2 years ago

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