簡體   English   中英

Xamarin C#:System.Reflection.TargetInvocationException

[英]Xamarin C#: System.Reflection.TargetInvocationException

我需要在Xamarin.Forms APP中使用WebService(SOAP)。 我在PCL中將webService導入為“服務參考”。

然后我將webService稱為:

  //...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 thrown by the target of an invocation.

int a = 12;僅用於斷點)PD:我使用此鏈接獲取示例http://developer.xamarin.com/guides/cross-platform/application_fundamentals/web_services/

我發現了問題。 Xamarin Android需要通通HttpGet和HttpPost協議。 這些協議必須在SideServer上生成。 以以下形式添加協議:

https://msdn.microsoft.com/en-us/library/4yx7be39(v=vs.100).aspx

最后:System.reflexion.Exception可能是由服務器的空響應引起的。(協議不正確)

PD:請記住使用仿真器/設備上的瀏覽器查看到webService(link webService)的正確導航,還請記住localhost是指向設備/仿真器的無效鏈接。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM