【发布时间】:2011-02-24 16:02:20
【问题描述】:
我们正在构建 Silverlight 应用程序并调用 Silverlight-WCF 服务。从 Visual Studio 运行应用程序时,一切正常。当我们部署到网站并运行应用程序时,每次调用 Web 服务时都会收到以下错误(或类似错误)。
Message: Unhandled Error in Silverlight Application An exception occurred during the operation, making the result invalid. Check InnerException for exception details. at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
at SSS.MVVMCore.Silverlight.WebPortalService.GetThemeIdCompletedEventArgs.get_Result()
at SSS.MVVMCore.Silverlight.ViewModels.StandardBaseFrameViewModel.<.ctor>b__0(Object s, GetThemeIdCompletedEventArgs ea)
at SSS.MVVMCore.Silverlight.WebPortalService.WebPortalServiceClient.OnGetThemeIdCompleted(Object state)
Line: 1
Char: 1
Code: 0
URI: http://ssswebportal.com/login.aspx?p=d53ae99b-06a0-4ba7-81ed-4556adc532b2
根据他的消息,该服务被调用并完全执行,但是当它尝试将结果反序列化回 Silverlight 应用程序时出现问题。关于正在发生的事情以及我们可以做些什么来解决它的任何建议?
>>>>> >>>>>>>>>>>>>>
这是我们的决议:
在 ServiceReferences.ClientConfig 文件中,我们有以下代码:
<client>
<endpoint address="http://localhost:5482/WebPortalService.svc"
binding="customBinding" bindingConfiguration="CustomBinding_WebPortalService"
contract="WebPortalService.WebPortalService" name="CustomBinding_WebPortalService" />
</client>
注意“本地主机”行。发布的时候需要是我们的web服务器地址,开发的时候需要是localhost。
任何人对如何自动完成此操作有任何建议,这样我们就不必在每次发布之前手动更改此行?
【问题讨论】:
-
您应该能够通过传入 EndpointAddress 和 Binding 对象在代码中创建服务代理,而无需回复 ServiceReferences.ClientConfig 中设置的配置。也许您可以自己管理端点的配置并使用某种#if DEBUG 来代替 localhost。
标签: silverlight wcf web-services serialization