【问题标题】:Deployed Silverlight application exception when calling a WCF Service调用 WCF 服务时部署 Silverlight 应用程序异常
【发布时间】:2010-03-25 22:25:35
【问题描述】:

silverlight 应用程序运行,但是当它调用我得到的服务时:

运行过程中出现异常,导致结果无效。检查 InnerException 以获取异常详细信息。 在 System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary() 在 SalesSimplicityPO_SL.POSvc.GetPurchaseOrdersCompletedEventArgs.get_Result() 在 SalesSimplicityPO_SL.About.mySvc_GetPurchaseOrdersCompleted(对象发送者,GetPurchaseOrdersCompletedEventArgs e) 在 SalesSimplicityPO_SL.POSvc.POSvcClient.OnGetPurchaseOrdersCompleted(对象状态)

我加载并调用我的网络服务,例如..

    BasicHttpBinding binding = new BasicHttpBinding();
    EndpointAddress address = new EndpointAddress(new Uri("http://localhost/POSystem/POSvc.svc"));
    POSvc.POSvcClient mySvc = new POSvc.POSvcClient(binding, address); 
    mySvc.InsertPOCompleted += new EventHandler<SalesSimplicityPO_SL.POSvc.InsertPOCompletedEventArgs>(mySvc_InsertPOCompleted);
    mySvc.InsertPOAsync(InitialsTextBox.Text.ToString(), DescTextBox.Text.ToString(), ClientTextBox.Text.ToString());

在调试中效果很好......

我做错了什么来得到这个错误?


更新:

我真的不明白为什么它修复了它,但这修复了它..也许有人可以提供一些信息......

我变了

EndpointAddress address = new EndpointAddress(new Uri("http://localhost/POSystem/POSvc.svc"));  

 EndpointAddress address = new EndpointAddress(new Uri(Application.Current.Host.Source, "../POSvc.svc")); 

【问题讨论】:

  • Check InnerException for exception details了吗?
  • 哈哈,除非我是个白痴(这是可能的......),这是内部异常在上面..它以 System.ComponentModel.AsyncCompletedEventArgs 开头......
  • 这是外部异常,位于 EventArgs 的 Error 属性中。检查e.Error.InnerException
  • 好吧,现在说得通了.. 提出了更多问题,但这就是它的美妙之处,好吗?谢谢

标签: c# silverlight wcf deployment


【解决方案1】:

这是因为 silverlight 不像 ASP.NET 那样解析虚拟路径。要转到根 ASP.NET 文件夹,您必须使用 Application.Current.Host.Source

【讨论】:

    【解决方案2】:

    我真的不明白为什么它修复了它,但这修复了它..也许有人可以提供一些信息......

    我变了

    EndpointAddress address = new EndpointAddress(new Uri("http://localhost/POSystem/POSvc.svc"));  
    

     EndpointAddress address = new EndpointAddress(new Uri(Application.Current.Host.Source, "../POSvc.svc")); 
    

    【讨论】:

    • 将此附加信息移至主要问题的更新中。
    猜你喜欢
    • 2011-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-15
    • 2023-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多