Xamarin.Forms 2.4.0.282: Object reference not set to an instance of an object

GyllionGyllion NLMember ✭✭

Hello everyone, I have encountered something after installing the Xamarin.Forms update (2.4.0.282) into my PCL. Whenever I try to rebuild my solution, it gives the following error for each XAML file in the PCL: "Object reference not set to an instance of an object". This message is unclear to me, but I discovered something interesting: Whenever I downgrade to Xamarin.Forms version 2.3.4.270, the project compiles. When I put it back to version 2.4.0.282, the error messages show up again.

I have tried several options, including deleting the 'bin' and 'obj' folders and restoring packages. None of them work so far, and I tried to run the project on different PC's. The error messages show up on every PC so far, so it is safe to assume that the problem lies in the project itself.

Has anyone encountered this problem aswell?

Best Answer

Answers

  • GVxGVx USMember ✭✭✭

    @Gyllion I came across the same issue.... I just removed the Xaml Compile option from all my .cs files.... This isn't the ideal option as pre-compiling xaml is supposed to be a good thing to have but I found no other way to fix the issue....

  • marcnegrimarcnegri CHMember ✭✭

    @Gyllion

    Hi,

    I had the same issue and did the same thing : removed Xaml compile option... :neutral:

  • GyllionGyllion NLMember ✭✭

    @GVx @marcnegri

    Thanks for the anwsers! There is only one problem: I'm using the framework Prism, which does not contain that attribute. I fixed the problem by making a new Prism project and moving all the files to the new project (views, viewmodel, services, etc.). It works now, but I can imagine that this solution would be harder for other developers to adapt.

  • NMackayNMackay GBInsider, University ✭✭✭✭✭

    @Gyllion said:
    @GVx @marcnegri

    Thanks for the anwsers! There is only one problem: I'm using the framework Prism, which does not contain that attribute. I fixed the problem by making a new Prism project and moving all the files to the new project (views, viewmodel, services, etc.). It works now, but I can imagine that this solution would be harder for other developers to adapt.

    That attribute has nothing to do with Prism, it's a Forms attribute to make the XAML code compile to code rather than been built at runtime (much slower), my Prism app has Xaml compilation enabled in every page.

  • PriyaGaikwadPriyaGaikwad INMember ✭✭

    @ValentasMatusevicius I am facing same issue after Xamarin.Forms update (2.4.0.282). I have removed [XamlCompilation(XamlCompilationOptions.Compile)] but still issue persist.

    Please suggest any solution for this.

  • NMackayNMackay GBInsider, University ✭✭✭✭✭

    @PriyaGaikwad said:
    @ValentasMatusevicius I am facing same issue after Xamarin.Forms update (2.4.0.282). I have removed [XamlCompilation(XamlCompilationOptions.Compile)] but still issue persist.

    Please suggest any solution for this.

    That suggests your XAML is not formed correctly, unfortunately the parser does not give a helpful error with the line number etc and throws this error, I had this the other day because my margin was set to "0,00,0"

  • PriyaGaikwadPriyaGaikwad INMember ✭✭

    @NMAckay Thanks for Reply. I will check it :)

  • StephenWilkinsonStephenWilkinson USMember ✭✭

    I'm getting this error too now after updating to VS Mac 7.2.2 (Build 11) - no changes to my .xaml files. Doing a clean, rebuild, clear caches, reboot did not work. I had to remove all xaml compilation options as well to get it to work again.

  • anveanve DEMember ✭✭

    I updated to Xamarin Forms 2.5.0.91635 and I noticed that all code-behind files, which had a

    [XamlCompilation(XamlCompilationOptions.Compile)]
    

    in it produced the

    Object reference not set to an instance of an object

    error, when the application was built. So I removed it and now I can run my application again, but why is this? Is this a bug?

Sign In or Register to comment.