Xamarin C#:System.Reflection.TargetInvocationException [英] Xamarin C#: System.Reflection.TargetInvocationException
问题描述
我需要在 Xamarin.Forms APP 中使用 WebService(SOAP).我在 PCL 中将 webService 作为服务参考"导入.
I need consume a WebService(SOAP) in a Xamarin.Forms APP. I import the webService as "Service Reference" in PCL.
然后我将 webService 称为:
Then i call the webService as:
//...oncreate
Guid g1 = new Guid("3f0c9ec7-9382-403d-8480-7142a7fd65d9");
ws.GetNotificacionesAsync(g1);
ws.GetNotificacionesCompleted += ws_GetNotificacionesCompleted;
void ws_GetNotificacionesCompleted(object sender, WSPuentesUsuario.GetNotificacionesCompletedEventArgs e)
{
int a = 12;
}
最后,e"显示这个错误:Result = System.Reflection.TargetInvocationException: Exception has been throwed by the target of an invocation.
Finally, "e" show this error: Result = System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
(int a = 12;
仅用于断点)PD:我用这个链接怎么举例http://developer.xamarin.com/guides/cross-platform/application_fundamentals/web_services/
(int a = 12;
is only used to breakpoint)
PD: I use this link how example
http://developer.xamarin.com/guides/cross-platform/application_fundamentals/web_services/
推荐答案
我发现了问题.Xamarin Android 需要通信 HttpGet 和 HttpPost 协议.这些协议必须在 SideServer 上生成.以这种形式添加协议:
I found the problem. Xamarin Android need to comunicate the HttpGet and HttpPost protocols. These protocols must be generated on SideServer. Adds protocols this form:
https://msdn.microsoft.com/en-us/library/4yx7be39(v=vs.100).aspx
最后:System.reflexion.Exception 可能是由服务器的空响应引起的.(不正确的协议)
Finally: System.reflexion.Exception can be caused by a null response from server.(Incorrect protocols)
PD:记住使用模拟器/设备上的浏览器来查看正确的 webService 导航(链接 webService),还要记住 localhost 是一个无效的设备/模拟器链接.
PD: Remember use the browser on emulator/device to see the correct navegation to webService(link webService), also remember that localhost is a invalid link to device/emulator.
这篇关于Xamarin C#:System.Reflection.TargetInvocationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!