silverlight   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了解决 关于Silverlight使用WCF时抛出异常 Could not find default endpoint element that references contract...大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

环境是这样的 在solution中添加了一个WebSite,在WebSite中添加了一个Silverlight-enabled WCF service(添加普通的WCF service,在Silverlight中使用service reference时会报错。但是通过修改config和契约是可以使用的,这里简化背景,只适用Silverlight-enabled WCF servicE)。 再向so

环境是这样的

在solution中添加一个WebSite,在WebSite中添加一个Silverlight-enabled WCF service(添加普通的WCF service,在Silverlight中使用service reference时会报错。但是通过修改config和契约是可以使用的,这里简化背景,只适用Silverlight-enabled WCF servicE)。 再向solution中添加一个Silverlight Application,在这个application中添加刚才创建的Silverlight-enabled WCF service的service reference是可以调用成功的。之后再向solution添加一个Silverlight Library。把这个Library引用到刚才的Silverlight application中。并向Library中添加service reference。这时在这个Library中调用WCF服务会失败。抛出Could not find default endpoint element that references contract...

在网上找啊找也没有好的解决方案,看来只能靠自己了。分析异常报告,有这样一句

This might be because no configuration file was found for your application,or because no endpoint element matching this contract Could be found in the client element。

显然前半句的错误肯定不存在。serviceReferences.CLIENtConfig好好的躺在那呢。

那么只能是endpoint element在config找不到了。尝试着在ClientConfig中将契约添加命名空间,修改绑定类型等等都不起作用。

后来突然想到有Application加载Library,那么会不会需要在Applcation中的ClientConfig添加Library的endpoint呢?于是在Application的ClientConfig中尝试添加Library中用到的endpoint。重新编译,启动。成功调用。。。。。。

怎么说微软好呢。。。。。

总结解决方法,如果要在Silverlight的library中使用WCF需要在Sliverlight Applcation的config文件添加相应的endpoint

大佬总结

以上是大佬教程为你收集整理的解决 关于Silverlight使用WCF时抛出异常 Could not find default endpoint element that references contract...全部内容,希望文章能够帮你解决解决 关于Silverlight使用WCF时抛出异常 Could not find default endpoint element that references contract...所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。