The name 'InitializeComponent does not exist in the current context" Error

nandininadig.0478nandininadig.0478 USMember ✭✭
edited January 5 in Xamarin.Forms

Hi,

I installed the Windows Pro Version 10.0.16299 Build . When I create a new xamarin project and create a content page . I see that
.xaml.cs file is not nested under .xaml page and I get an error "The name 'InitializeComponent does not exist in the current context "
when I compile the project. The solution exploper in the visual studio does not show the .xaml file at all. Please refer to attached file.
I am using xamarin forms 2.5.0.121.934 and visual studio 15.5.2

Could anybody please help me on this issue?

Thanks

Posts

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Its a false error. Happens all the time.
    Just build the app and it will be fine.
    At most close the solution and re-open. The (Loading...) process does wonders especially on brand new solutions.

  • nandininadig.0478nandininadig.0478 USMember ✭✭

    Thanks for the reply. It does not help. I still get the same error. Did a clean build. Reopened the
    solution and compiled it.

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Seeing that in the designer means nothing.
    Does the app compile and run?

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭
    edited January 5

    I see that .xaml.cs file is not nested under .xaml page

    Just saw this. You have a problem with Visual Studio not being installed correctly/fully or with Xamarin support.

    visual studio 15.5.2

    Why aren't you using VS 2017? Why are you using an older IDE? It works.. but its a little harder to make sure you have everything installed. VS2017 is an integrated installer. Just turn on every workload and every option when you do the install.

  • nandininadig.0478nandininadig.0478 USMember ✭✭
    edited January 5

    Sorry I meant VS 2017 Version 15.5.2. There is some issue with latest visual studio or xamarin forms. The app does not compile.

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    There is some issue with latest visual studio or xamarin forms. The app does not compile.

    If it were VS or XF then there would be a thousand threads here with everyone failing.
    I don't have an issue with latest everything on my home machine. I just updated EVERYTHING in my house over Christmas vacation. Every Windows machine and softwares, the Mac, my phones, tablets, AppleTV, drone firmware, 3d Printer firmeware... everything.

    So unless it is some update within the last 4 days... I don't think its the IDE or Xamarin eco-system.

  • nandininadig.0478nandininadig.0478 USMember ✭✭

    ok. So when you create a brand new xamarin App on VS, are you able to create a content page successfully and build the App? It does not happen on old projects . But when you create a new content page on the older projects, the new pages that are created has the issue. Do u have windows pro or Enterprise OS?

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    So when you create a brand new xamarin App on VS, are you able to create a content page successfully and build the App?

    Yep. I've been doing it a LOT because I've been writing new Xamarin tutorials for my blog.

    Do u have windows pro or Enterprise OS?

    WindowsPro - You couldn't pay me enough to put Windows Enterprise on any machine I own.

  • nandininadig.0478nandininadig.0478 USMember ✭✭

    I see the error happening in Shared project but not when I create a page in the android project . Can you try creating page in shared project as PCL is not an options anymore? Thanks

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    as PCL is not an options anymore? Thanks

    PCL is deprecated and replaced with .NET Core. If you're used to using PCL just use .NET Core instead of changing your patterns over to shared.
    So the more import question is: Do you have this issue if you create a .NET core solution and add a page?

    I can give it a go in shared - but not until over the weekend. Here at work I have to ... well... work. And the office is still on VS2015 so it can't happen here anyway.

  • nandininadig.0478nandininadig.0478 USMember ✭✭

    Ok. Thanks. Please refer tot he screen shots below. This is how I am creating a new project and having the issue

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Again... If you were originally using PCL and wish you still could, why aren't you using the modern replacement for PCL which is .NET Standard?

  • nandininadig.0478nandininadig.0478 USMember ✭✭
    Thanks it works by selecting .NET standard option. There is issue with shared project for sure.
  • MikeStoneMaxMikeStoneMax USMember ✭✭

    I think I figured out what might be the cause of this. I had a similar issue after adding .xaml and the .xaml.cs files into an existing project.

    By default the Build Action is was on Page for the .xaml file. I changed it to Build Action: Embedded Resource. Then I saved the project and reload VS. I hope this helps!

Sign In or Register to comment.