Soap Xamarin PCL未处理的异常:TargetInvocationException

Soap Xamarin PCL未处理的异常:TargetInvocationException,soap,xamarin.ios,xamarin,dynamics-ax-2012,xamarin.forms,Soap,Xamarin.ios,Xamarin,Dynamics Ax 2012,Xamarin.forms,我正在制作一个移动应用程序,它可以使用WCF服务与Dynamics AX通信 我是Xamarin的新手,我正在尝试为共享的IOS和Android应用程序创建一个PCL库。我也在开发一款Windows Phone应用程序,现在已经可以正常工作了。Im使用我创建的WCF服务,该服务与Dynamics AX进行所有通信,该服务使用元数据公开其方法。我已经向Windows Phone解决方案添加了一个服务引用,生成的代理就像一个符咒,我应该说我在使用SOAP 但是,如果我将生成的Reference.cs

我正在制作一个移动应用程序,它可以使用WCF服务与Dynamics AX通信

我是Xamarin的新手,我正在尝试为共享的IOS和Android应用程序创建一个PCL库。我也在开发一款Windows Phone应用程序,现在已经可以正常工作了。Im使用我创建的WCF服务,该服务与Dynamics AX进行所有通信,该服务使用元数据公开其方法。我已经向Windows Phone解决方案添加了一个服务引用,生成的代理就像一个符咒,我应该说我在使用SOAP

但是,如果我将生成的Reference.cs文件传输到我的Xamarin PCL项目,并以完全相同的方式调用我的方法,则会出现以下错误:

Unhandled Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.Serialization.SerializationException: Expected element 'ExceptionDetail' in namespace 'http://schemas.datacontract.org/2004/07/System.ServiceModel', but found Element node 'AifFault' in namespace 'http://schemas.microsoft.com/dynamics/2008/01/documents/Fault'
  at System.Runtime.Serialization.XmlFormatterDeserializer.Deserialize (System.Xml.XmlReader reader, System.Type declaredType, System.Runtime.Serialization.KnownTypeCollection knownTypes, IDataContractSurrogate surrogate, System.Runtime.Serialization.DataContractResolver resolver, System.Runtime.Serialization.DataContractResolver defaultResolver, System.String name, System.String ns, Boolean verifyObjectName) [0x0003e] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/7.4.0.108/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:63 
  at System.Runtime.Serialization.DataContractSerializer.ReadObject (System.Xml.XmlDictionaryReader reader, Boolean verifyObjectName) [0x00024] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/7.4.0.108/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/DataContractSerializer.cs:363 
  at System.Runtime.Serialization.XmlObjectSerializer.ReadObject (System.Xml.XmlDictionaryReader reader) [0x00000] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/7.4.0.108/src/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlObjectSerializer.cs:76 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request (System.ServiceModel.Description.OperationDescription od, System.Object[] parameters) [0x0019b] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/7.4.0.108/src/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:550 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.DoProcess (System.Reflection.MethodBase method, System.String operationName, System.Object[] parameters) [0x00038] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/7.4.0.108/src/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:496 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Process (System.Reflection.MethodBase method, System.String operationName, System.Object[] parameters) [0x0001c] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/7.4.0.108/src/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:477 
  --- End of inner exception stack trace ---
该问题仅在AX返回AIFFault异常并且由于某些原因无法被Xamarin捕获时发生。。在WindowsPhone的VisualStudio中,它被捕捉到了

以下是拨打电话的代码:

try{
     var result = await _service.ExecuteGetMethod(MyRecord)
}
catch(FaultException fe){
     ShowError(fe);
}
这工作得很好,来自AX的错误消息显示在fe.message中,但在Xamarin中运行完全相同的命令会产生上述错误

我是否需要在WCF服务中的某个位置添加AIFFault,以便客户能够看到它