Initializecomponent does not exist in the current context

DharmendarDharmendar USMember ✭✭

Hi ,
I have updated my Xamarin Studio and Xamarin.Forms to 1.4.0.0, now when ever creating Xaml Page in portable
application , i'm getting build error as "Initializecomponent does not exist in the current context".Does any one faced this issue

Thanks in Advance

Best Answer

Answers

  • PrudveeKrishnaPrudveeKrishna USMember

    Please check namespace in .cs file, is it correct or not?namespace SearchResults { public partial class FirstPage : ContentPage { }}, and in XAML <?xml version="1.0" encoding="UTF-8"?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="SearchResults.FirstPage"> <ContentPage.Content>
    when we copy and paste code from another project, we forget to change namespace, this is one case for this error.

  • JesseMJesseM USMember ✭✭

    @RussellFustino - Worked for me after having the identical issue. Can't beat em? Join em

  • elefpelefp GRMember ✭✭
    edited February 2016

    I think I've found out what actually causes this irritating error, at least in my case. I noticed that the problem was gone as soon as I removed custom namespaces that I did not use from my XAML. They were forgotten there through various trial-error attempts for various things. It took me over 3 hours to realize it. Hope this may also help you too.

    I also noticed that using {x:Static customNamespace:whatever} having removed customNamespace from ContentPage's attributes, does NOT produce a compile error, but on run time the app is screwed up.

  • AlezhukAlezhuk USMember ✭✭

    Simply recreate a problem file in your project and you'll be fine :)

  • DevologyDevology GBMember ✭✭

    For what it's worth - I had this error today (I used a PCL approach) and simply went to the top-level solution node and updated the Xamarin Forms nuget package for all the projects. After that I cleaned and rebuilt and it worked no problem.

  • GaryMedinaGaryMedina USUniversity

    This is a bit old but I found a solution that seems to work when receiving this error currently in 4.7.

    If you change the Build Action of the error page to none (or anything other) then change the Build Action back to Embedded Resource the error goes away.

Sign In or Register to comment.