locked
Visual Studio 2013 Express for Windows - InitializeComponent() does not contain a definition issue

    Question

  • Hi,

    I have recently downloaded Visual Studio 2013 Express for Windows (Windows Store App version), with Update 1.

    I create a blank app. I right-click on InitializeComponent() in the MainPage.xaml.cs and select Go To Definition. It brings me to the .g.i.cs file where this method resides.

    I go into the designer for MainPage.xaml and create a grid of 2 rows and 2 columns (all at 1*). I add one button, doesn't matter where. I double click on that button to add a click method to MainPage.xaml.cs. Without entering anything into the button click method, I scroll up and InitializeComponent() has an error and tells me there is not definition, even though I was looking at the definition a minute ago. I found I could unload the project and reload it and InitializeComponent() would have the definition in the .g.i.cs file but as soon as I add another button click or anything else I run into the same error. It seems as if the .g.i.cs file is not automatically regenerating, or it is being deleted all together when the button click method is added to the xaml.cs file.

    Everything I have done up to this point is very vanilla. I installed VS '13 Express for Windows, didn't change any VS setting, created a project and ran into this issue. I installed Update 1 thinking there might be a fix from the update--no luck. The xaml file Build Action is Page and the Xaml.cs file is Compile.

    I have tried deleting the MainPage.xaml file, after the creation of a project, and adding a new MainPage file with the added templates VS wants to include, and I still run into the same issue.

    I have searched for answers the past few days but haven't found anything that addresses my issue (most of what I found addresses VS '10 but their InitializeComponent() issues aren't the same as mine). Any help the MSDN community can provide would be a great help. If worst comes to worst, I will re-install VS and see if that corrects it--this would be a last-ditch effort though.

    Thank you for any help you may be able to provide

    Friday, April 25, 2014 1:22 AM

Answers

  • Intellisense has a bug in VS2013 where it doesn't recognize InitializeComponent when you start working on the XAML.  My feeling is that if you try to compile this app, it will run fine (as long as there are no actual errors).


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by BEGamache Thursday, May 01, 2014 7:01 PM
    Friday, April 25, 2014 12:39 PM
    Moderator

All replies

  • Intellisense has a bug in VS2013 where it doesn't recognize InitializeComponent when you start working on the XAML.  My feeling is that if you try to compile this app, it will run fine (as long as there are no actual errors).


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by BEGamache Thursday, May 01, 2014 7:01 PM
    Friday, April 25, 2014 12:39 PM
    Moderator
  • Error    1    'PSGDisasterPHUniversal.MainPage' does not contain a definition for 'InitializeComponent' and no extension method 'InitializeComponent' accepting a first argument of type 'PSGDisasterPHUniversal.MainPage' could be found (are you missing a using directive or an assembly reference?)    c:\users\patrick\documents\visual studio 2013\projects\psgdisasterphuniversal\psgdisasterphuniversal\psgdisasterphuniversal.windowsphone\mainpage.xaml.cs    29    18    PSGDisasterPHUniversal.WindowsPhon

    if i try to build it the error appears

    Friday, January 02, 2015 11:46 AM