我们正在构建一个 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>
注意“localhost”行。当我们发布时,它需要是我们的网络服务器地址,但在开发时,它需要是本地主机。
任何人对如何自动完成此操作有任何建议,以便我们不必在每次发布之前手动更改此行?