微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在 Xamarin Forms 中使用 WCF 服务

如何解决在 Xamarin Forms 中使用 WCF 服务

我希望通过基于 this sample code 的 Xamarin Form 连接到 WCF 服务(在 Windows PC 上运行)。 我成功地找到并创建了指向 WCF 的连接服务。并且我采用了之前在 UWP 环境中使用的相同方法

但是一旦我调用了服务中公开的任何方法,我就会在 Android 环境中得到这个异常。 The method or operation is not implemented

我不使用 PCL 风格,而是 .net 方式。

enter image description here

这里是异常的堆栈跟踪。

  at System.ServiceModel.Channels.BindingContext.BuildInnerChannelFactory[TChannel] () [0x00007] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BindingContext.cs:149 
  at System.ServiceModel.Channels.BindingElement.BuildChannelFactory[TChannel] (System.ServiceModel.Channels.BindingContext context) [0x0000e] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BindingElement.cs:52 
  at System.ServiceModel.Channels.BinaryMessageEncodingBindingElement.BuildChannelFactory[TChannel] (System.ServiceModel.Channels.BindingContext context) [0x0000e] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BinaryMessageEncodingBindingElement.cs:94 
  at System.ServiceModel.Channels.BindingContext.BuildInnerChannelFactory[TChannel] () [0x00007] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BindingContext.cs:149 
  at System.ServiceModel.Channels.Binding.BuildChannelFactory[TChannel] (System.ServiceModel.Channels.BindingParameterCollection parameters) [0x0000e] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Binding.cs:133 
  at System.ServiceModel.ChannelFactory.CreateFactory () [0x000be] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory.cs:202 
  at System.ServiceModel.ChannelFactory.Onopening () [0x00006] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory.cs:383 
  at System.ServiceModel.Channels.CommunicationObject.Processopening () [0x00017] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CommunicationObject.cs:276 
  at System.ServiceModel.Channels.CommunicationObject.Open (System.TimeSpan timeout) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CommunicationObject.cs:169 
  at System.ServiceModel.Channels.CommunicationObject.Open () [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CommunicationObject.cs:164 
  at System.ServiceModel.ChannelFactory.EnsureOpened () [0x0004c] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory.cs:297 
  at System.ServiceModel.ChannelFactory`1[TChannel].CreateChannel () [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory_1.cs:108 
  at System.ServiceModel.DuplexClientBase`1[TChannel].CreateChannel () [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System.ServiceModel/System.ServiceModel/DuplexClientBase.cs:123 
  at System.ServiceModel.ClientBase`1[TChannel].get_InnerChannel () [0x00008] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System.ServiceModel/System.ServiceModel/ClientBase.cs:186 
  at System.ServiceModel.ClientBase`1[TChannel].get_Channel () [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System.ServiceModel/System.ServiceModel/ClientBase.cs:192 
  at AppMobileService.AppMobileCommandHandlerClientBase.SubscribeAsync (System.String name,AppMobileService.AppMobileConnectionType connectionType) [0x00001] in C:\Users\adm\Desktop\AppMobilePortable\AppMobilePortable\AppMobilePortable\Connected Services\AppMobileService\Reference.cs:945 
  at PortableAppMobile.Services.AppMobileClientService.Connect () [0x00024] in C:\Users\adm\Desktop\AppMobilePortable\AppMobilePortable\AppMobilePortable\Service\AppMobileClientService.cs:136  ```

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。