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

SRSSRS USMember ✭✭

I Created a brand new Xamarin.forms project with Visual studio 2017, when i try to compile after creating the project, i'm getting the below error, I didn't change single line of code.

"Error CS0103 The name 'InitializeComponent' does not exist in the current context App2.iOS D:\App2\App2\App2\App.xaml.cs 14 Active"

other info : It is successfully connected to a Mac machine

Answers

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Clean the solution
    Close it
    Open it - So it goes through the (Loading...} process on each project
    Build each project one at a time - not Rebuild Solution.

    Should be good now. Its fairly common, especially on new solutions built the first time.

  • SRSSRS USMember ✭✭

    No luck, did as you mentioned, Android App compiled fine, with ios got an extra error.

    Error No installed provisioning profiles match the installed iOS signing identities. App2.iOS
    Error CS0103 The name 'InitializeComponent' does not exist in the current context App2.iOS D:\App2\App2\App2\App.xaml.cs 14 Active
    Error CS0103 The name 'InitializeComponent' does not exist in the current context App2.iOS D:\App2\App2\App2\MainPage.xaml.cs 14 Active

  • SRSSRS USMember ✭✭

    I created one more project, same result.

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    As a test... Humor me... Walk through this series... http://www.RedPillXamarin.com
    That's my site. I know it works on both VS2015 and VS2017. Its a known-good quantity.
    If you can't build that solution from start to end you probably have an issue with your Visual Studio installation.

  • SRSSRS USMember ✭✭

    I think may be a installation issue, i'm using windows 7 & Xamarin recommends windows 8 and above.

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Eh... Time to in update to Win10

  • I'm having this same issue. I've tried everything suggested and also tried Uninstalling/Reinstalling the NuGet for Xamarin.Forms. I'm running Win 10 Creators with VS 2017 Enterprise.

    Are there really no experts at MS/Xamarin that have more suggestions?

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Everyone sees this all the time with a new project.
    Typically:

    @ClintStLaurent said:
    Clean the solution
    Close it
    Open it - So it goes through the (Loading...} process on each project
    Build each project one at a time - not Rebuild Solution.
    Should be good now. Its fairly common, especially on new solutions built the first time.

    Gets you on track.

    On the other hand, the new "workloads" concept of VS2017 sucks. You can't rely on just installing the "cross-platform" workload: It doesn't have everything you need. Install EVERYTHING. Every option, every workload, every package, then every optional add-on in the right-hand pane. Everything including the kitchen sink.

  • LentoManLentoMan SEMember ✭✭

    If you take a look at the classes with the errors you will notice that they are actually partial classes, the InitializeComponent() method is part of an autogenerated partial class which is based on the .xaml file (the generated class extends the top component in the xaml, for example ContentPage).

    Using a file browser or the show all files option in solution explorer, you should be able to find the autogenerated classes in the obj\debug folder at the root of your projects containing .xaml files. The autogenerated classes has the extension .xaml.g.cs.

    If those files aren't generated, usually cleaning/rebuilding the solution will help or sometimes cleaning, restart VS and then rebuilding. It could also be that your xaml files are invalid, or that there is something wrong with your VS installation.

  • hutchinskihutchinski USMember ✭✭

    I am using Visual Studio 2017 Community Edition, and Windows 10. I have updated all Xamarin Forms components. The only solution I found was the one quoted above ( which really helped - thank you ). i.e.
    Changing the .XAML file Build Action properties to Content, then back again to Embedded Resource.

  • Jason_DeBoeverJason_DeBoever USXamarin Team, University, XamUProfessors Xamurai

    The build action work-around works, but can be annoying if you have many files with the problem. Deleting your ".vs" (hidden meta-data) folder and then re-opening the solution often fixes this for all files in the solution.

  • RodeKubaiziRodeKubaizi USMember ✭✭

    @MichaelMcCarty.8792

    Worked for me !!!!!!!
    check the property of the xaml file and make sure it is embedded resource
    thanks

Sign In or Register to comment.