Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Backdoor Invoke() Error

$
0
0

I'm calling my backdoor method via my tests. Somehow in my AppDelegate.cs it causes the Xamarin test to crash and have an exception error:

System.Exception: Error while performing Invoke("nameMethod", null)
--> System.Net.WebException : Error getting response stream (ReadDone 2): ReceiveFailure
--> System.Exception: at System.Net.WebConnection.HandleError(WebExceptionStatus st, System.Exception e, System.String where)
at System.Net.WebConnection.ReadDone(IAsyncResult result)

My AppDelegate backdoor method is:

[Export ("getPageTitle:")]
public NSString GetPageTitle (NSString s)
{
        Page page = App.Current.MainPage; //somehow I narrowed down to this line, this crashes the whole thing
        if (page != null)
        {
          return new NSString(page.Title);
        }
        return new NSString("No page found");
}

My call:

[Test()]
public void SomeMethod()
{
    app.Invoke("getPageTitle");
}

Is it not possible to get the App context here? What am I doing wrong?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>