Exception Unhandled when selecting a page from Master Deatail Nav Template

jenova1628jenova1628 Member ✭✭
edited February 11 in Xamarin.Forms

Hi I am trying to load a JSON file when I go to a page on my app but when I select the page using the Master Detail Page Navigation template it throws this error:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation

which the code its highlighting is in the MainPage.xaml.cs:

Detail = new NavigationPage((Page)Activator.CreateInstance(item.TargetType));

In my LoadJson class it happens just after the Using line:

    `public void LoadJson()
    {
        //Loads the JSON File in the Solution and Finds Correct ID of Accordion Hopefully!!
        var assembly = typeof(App).GetTypeInfo().Assembly;
        Stream stream = assembly.GetManifestResourceStream("MasterDetailPageNavigation.TimeSheet.json");

        string jsonString = "";
        using (var reader = new StreamReader(stream))
        {
            jsonString = reader.ReadToEnd();
        };

        uoObj = JsonConvert.DeserializeObject<RootObject>(jsonString);
    }`

the JSON is in the root of my PCL so i believe the above is correct. can anybody help

Tagged:

Best Answer

  • jenova1628jenova1628 ✭✭
    Accepted Answer

    After looking at the code it turns out the JSON was not an Embedded Resource! Changing This has solved the problem!

Answers

  • jenova1628jenova1628 Member ✭✭
    Accepted Answer

    After looking at the code it turns out the JSON was not an Embedded Resource! Changing This has solved the problem!

Sign In or Register to comment.