首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在动态加载的ServiceReferences.ClientConfig文件中读取Silverlight 3中WCF中的.xap

在动态加载的ServiceReferences.ClientConfig文件中读取Silverlight 3中WCF中的.xap
EN

Stack Overflow用户
提问于 2009-10-23 16:50:22
回答 1查看 2.9K关注 0票数 0

我用的是Silverlight 3棱镜(CAB)和WCF

当我在Prism模块中调用WCF服务时,我会得到相同的错误:

“无法在服务模型客户端信任部分找到引用合同'IMyService‘的默认端点元素。这可能是因为您的应用程序没有找到信任保护文件,或者因为在客户端元素中找不到与此契约匹配的端点元素。”

事实证明,它在Shell的.xap文件中查找ServiceReferences.ClientConfig文件,而不是在模块的ServiceReferences.ClientConfig文件中。我在Silverlight Shell应用程序中添加了端点并绑定到现有的ServiceReferences.ClientConfig文件(它调用自己的WCF服务)。

然后,我必须重新构建Shell应用程序来为我的网络项目的.xap文件夹生成新的ClientBin文件。

接下来,我更改为在代码中设置服务:

代码语言:javascript
复制
// create the binding elements
BinaryMessageEncodingBindingElement binaryMessageEncoding = new BinaryMessageEncodingBindingElement();
HttpTransportBindingElement httpTransport = new HttpTransportBindingElement() 
{ MaxBufferSize = int.MaxValue, MaxReceivedMessageSize = int.MaxValue};

HttpsTransportBindingElement httpsTransport = new HttpsTransportBindingElement() 
{ MaxBufferSize = int.MaxValue, MaxReceivedMessageSize = int.MaxValue };

// add the binding elements into a Custom Binding
CustomBinding customBinding;
if (Application.Current.Host.Source.Scheme.Equals("https", StringComparison.InvariantCultureIgnoreCase))
{
    customBinding = new CustomBinding(binaryMessageEncoding, httpsTransport);
}
else
{
    customBinding = new CustomBinding(binaryMessageEncoding, httpTransport);
}

// create the Endpoint URL
EndpointAddress endpointAddress = new EndpointAddress(

"http://localhost/Test/TestModule/Test.TestModule.WCF/TestModuleService.svc");

// create an interface for the WCF service
var service = new TestModuleServiceClient(customBinding, endpointAddress);
EN

回答 1

Stack Overflow用户

发布于 2009-10-27 17:40:04

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1614669

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档