locked
The name 'InitializeComponent' does not exist in the current context RRS feed

  • Question

  • I just installed Visual Studio 2008 Beta 2 and the Acropolis August CTP. But if I want to compile an newly generated Acropolis app generated with the wizard I get the following compiler error:

     

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

     

    Although in the readme is noted that you have to change the csproj I already have ToolsVersion="3.5" in there.

     

    Any Ideas, what is wrong with my setup?

     

    Regards,

    Thomas

    Wednesday, August 22, 2007 12:08 PM

Answers

  • Hi Thomas,

    Could you please check your Application.xaml and your Parts (<part_name>.xaml). If you select the file in the solution explorer and then look at the property grid the Build Action property should be set to "Acropolis Component". Somehow I am guessing this may be set to "Page": http://www.bulankou.com/files/buildaction.jpg

     

    If it is not, try setting it to "Acropolis Component", rebuild and check if the error still repros. Note that this only applies to your Application and Part's. The shell (Window.xaml) and the Views should still be set to "Page".

    Hope it helps!..

    Thursday, August 23, 2007 6:31 AM

All replies

  • Hi Thomas,

    Could you please check your Application.xaml and your Parts (<part_name>.xaml). If you select the file in the solution explorer and then look at the property grid the Build Action property should be set to "Acropolis Component". Somehow I am guessing this may be set to "Page": http://www.bulankou.com/files/buildaction.jpg

     

    If it is not, try setting it to "Acropolis Component", rebuild and check if the error still repros. Note that this only applies to your Application and Part's. The shell (Window.xaml) and the Views should still be set to "Page".

    Hope it helps!..

    Thursday, August 23, 2007 6:31 AM
  • Hi Alex,

     

    the Build Action for Application.xaml is set to Acropolis Component and the one for Window1.xaml to Page. If I set the one for Application.xaml to Page this error is gone, but obviously I get the following (:-():

     

    Error 1 Program '...AcropolisApp1.exe' does not contain a static 'Main' method suitable for an entry point AcropolisApp1

     

    :-) Thomas

    P.S.: BTW I just installed VS 2008 on this machine and did not change anything the wizard created. On another machine I have VS Orcas and the Acropolis July 2007 CTP, where everything seems to works fine.
    Thursday, August 23, 2007 6:52 AM
  • InitializeComponent will be undefined if the VS-generated code-behind for the item is not generated, which typically happens when there is a problem with the xaml itself.  Try this:

     

    1. Comment out InitializeComponent()

    2. Try building -- if it works, then there is likely an issue in your xaml

    3. Either way, open the xaml file and comment out any tags that are showing as errors (i.e. are underlined squiggly).  Worst case, take it back to blank content.

    4. Save the xaml file

    5. Uncomment the InitializeComponent() line

    6. Build -- if this works, then the original xaml did have an issue and you need to look closely at what you are doing (and specifically at the squiggly bit, if there was one Wink

     

    I had this issue where I had an opening Style tag that looked like this:

     

    Code Snippet
    <Style TargetType="Awx:PartPane" BasedOn="{StaticResource {x:Type Awx:PartPanel}}">

     

     

     

    Looks good right?  Wrong!  The last part of the tag says PartPanel instead of PartPane.  This 'looked' right to me (Panel is even a meaningful word!), but when I built, I didn't get an error here but instead got your error above (I did have a squiggly though, but ignored it because it looked right to me and because my experience told me that sometimes VS2008 seems to squiggle for no reason).

     

    Hope this helps... D

    Friday, August 24, 2007 2:41 PM
  • Thomas,

     

    I had this same problem and after failing to find an answer in this thread, I looked at the Expense sample app and got an idea when I was able to right click on the InitializeComponent() method in that app and use Go To Definition to get to some generated code in a file named Expense.Application.g.cs.  In my newly created WPF Application, I was getting the same error that you got and I had the thought to repair my Acropolis August CTP installation in Add/Remove programs. 

     

    After doing do, I generated a new Acropolis WPF Application and was then able to build successfully (and I could use Go To Definition to get to a similarly generated xx.g.cs file).

     

    For the record, I had repaired my VS 2008 Beta 2 installation after installing the Acropolis August CTP and I guessing that caused a problem which was corrected by also repairing the Acropolis installation.  Perhaps this will help you also.

     

    Regards,

     

    Chris

    Sunday, August 26, 2007 2:12 AM
  • Hi Chris,

     

    yes this worked for me too. After repair, I can compile newly generated apps and run the samples (which was not possible before).

     

    Thanks,

    :-) Thomas

     

    Monday, August 27, 2007 8:59 AM