2011-01-14 47 views
0

有很多关于此主题的文章,但都没有帮助我。我试图实施可以在没有“添加服务参考...”的情况下使用的服务,主要是通过http://www.netfxharmonics.com/2008/11/Understanding-WCF-Services-in-Silverlight-2的建议。Silverlight客户端从WCF获得NotFound错误

我做了一个小项目来重现问题。 http://hotfile.com/dl/96710945/9991ac3/SilverlightApplication8.zip.html

我试着像解决方案:
- 在Silverlight 处理故障 - 跨域策略 等

所有标准检查等服务,然后到达完成,客户端成功创建通道等

我整个一周都有这个问题,我无法弄清楚。

每一个帮助是明智的。

+0

您应该设置并将服务添加到没有接口的svc文件的代码隐藏。这就是Silverlight的工作原理。 – vorrtex 2011-01-14 22:47:23

+0

使用SvcTraceViewer.exe我发现了以下错误:“无法查找通道接收传入的消息,无法找到端点或SOAP操作。” – 2011-01-17 08:51:11

回答

0

我没有深入调查,但我认为服务实现类的类型不好。

所以我的工厂类看起来像:

公共类TimeServiceFactory 继承System.ServiceModel.Activation.ServiceHostFactoryBase

Public Overrides Function CreateServiceHost(ByVal constructorString As String, ByVal baseAddresses() As System.Uri) As System.ServiceModel.ServiceHostBase 
    Dim host As New ServiceHost(constructorString, baseAddresses) 

它需要在改变:

公共类TimeServiceFactory 继承System.ServiceModel.Activation.ServiceHostFactoryBase

Public Overrides Function CreateServiceHost(ByVal constructorString As String, ByVal baseAddresses() As System.Uri) As System.ServiceModel.ServiceHostBase 
    Dim host As New ServiceHost(GetType(TimeService), baseAddresses) 

区别在于我没有通过constructorString(它具有服务类实现类的信息),我通过了GetType(TimeService)instate,它提供了正确的类型信息。

0

丹尼斯, 尝试在您的虚拟主机项目中创建服务。在那里添加服务,然后你可以选择在Silverlight应用程序中添加它作为参考。只需在SilverlightApplication8.Web中添加一项服务即可。右键单击SilverlightApplication8.Web - >添加新项目 - >在左侧选择Silverlight - >启用Silverlight的WCF服务。然后添加对SilverlightApplication8的引用。

相关问题