locked
wp8 build error="The name 'InitializeComponent' does not exist in the current context" in app.xaml.cs." RRS feed

  • Question

  • I added a new xaml page to my project and copy and pasted some regular snippets to it that I've done before to many other pages.  After all the changes looked good to me, I did a rebuild and got this error in the app.xaml.cs which I hadn't changed. I also get the same error in the new page I created.  It seems that the xaml design and code are not linked because there are other build errors in the new page's code file that reference other controls in it's design.  Those references also look ok to me but they get the similar "The name '.....' does not exist." error. 

    

    walter fink

    Saturday, January 3, 2015 3:35 PM

Answers

All replies

  • Hi Wfink,

    DisplacedGuy provided a solution in this thread with the same error:

    http://stackoverflow.com/questions/17853898/the-name-initializecomponent-does-not-exist-in-the-current-context-cannot-get

    Please reference it, maybe it can help you.

    If no help, please create a new windows phone 8(I assume wp8 means windows phone 8) project and copy the regular snippets to the default xaml page and then build the project to check whether the same error will occur. Note:This step will help to check whether the issue is on the specific project or the code snippets.

    If the template project also has the error, then there is anything wrong with your VS. Especially maybe there is anything wrong with the project template. I suggest you should delete your ItemTemplatesCacheProjectTemplatesCache folder and then run the the devenv /InstallVSTemplates switch and devenv /Setup switch. Please refer to the following steps:

    Step1: Please open Windows Explorer, and navigate to <Visual Studio Installation Path>\Common7\IDE (by default is <C:\Program Files(x86) \Microsoft Visual Studio 12.0\Common7\IDE>)

    Step2:  Delete the ItemTemplatesCacheProjectTemplatesCache folder; 

    Step3: Open Visual Studio Command Prompt (2013 x64 Cross Tools Command Prompt under Start menu -> All Programs -> Microsoft Visual Studio 2013 -> Visual Studio Tools (run it with Administrator privilege: right-click the program -> Run as administrator); 

    Step4: Run the devenv /InstallVSTemplates switch and the devenv /Setup switch

    Reference:

    http://msdn.microsoft.com/en-us/library/ms241279.aspx

    http://msdn.microsoft.com/en-us/library/ex6a2fad.aspx

    If this issue only occurred in the specific project, then this issue is on the project itself, maybe something affected your project, please delete the .suo file from the solution directory which will help to recreate user settings, please see: Solution User Options (.Suo) File. If no help, please create the project from scratch. Or you can consult on Windows Phone Development forum: https://social.msdn.microsoft.com/Forums/windowsapps/en-us/home You may get help there.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    • Edited by Amanda Zhu Tuesday, January 6, 2015 2:14 AM update
    Monday, January 5, 2015 8:21 AM
  • This help seems ludicrus.  The steps suggested are difficult with no explanations why each is needed.   The link has people suggesting to change build actions.  Those are easy to do with the repro project I attached to the forum but they produce different app.xaml.cs errors.

    walter fink

    Monday, January 5, 2015 8:59 PM
  • Hi Walter Fink,

    I am sorry that I did not explain the suggestions well. I update my last post ad make some explanation. Please try those suggestions and tell us the result.

    Those are easy to do with the repro project I attached to the forum but they produce different app.xaml.cs errors.

    I don’t see the attached repro project in this forum. Maybe I misunderstood you?

    Thanks,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, January 6, 2015 2:16 AM
  • The attacment was made to the original location of my issue which was a problem report to Microsoft. They somehow duplicated it here in the forum.  I don't know why the attachment doesn't show in the forum also.  I don't see anyway that I can attach it here in the forum myself.

    walter fink

    Tuesday, January 6, 2015 2:50 PM
  • Hi,

    You don’t have “x:Class="DIYMedAPP.App"” in your App.xaml file, which caused such error in App.xaml.cs. Please add it.

    <Application

        x:Class="DIYMedAPP.App"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"

        xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone">

        <!--Application Resources-->

        <Application.ApplicationLifetimeObjects>

            <!--Required object that handles lifetime events for the application-->

            <shell:PhoneApplicationService

                Launching="Application_Launching" Closing="Application_Closing"

                Activated="Application_Activated" Deactivated="Application_Deactivated"/>

        </Application.ApplicationLifetimeObjects>

    </Application>


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Amanda Zhu Friday, January 9, 2015 3:16 AM
    • Unproposed as answer by wfink Friday, January 9, 2015 8:29 PM
    Wednesday, January 7, 2015 4:16 AM
  • I never needed that in my app.xaml when it built cleanly.  I just added it anyway since you suggest it but I get this new error when I build.  It is the only error now:

    Error 45 Application manifest generation failed. Cannot find the app manifest template file C:\svn\DIYMedAPP\DIYMedAPP\Properties\AppManifest.xml.

    This new error seems appropriate because the manifest file I have in my properties folder is named WMAppManifest.xml.  I did not create this file, vs2013 did.  I'm afraid to change it.  Anyway my issue is a bug report with Microsoft and they seem to have responded elsewhere in emails to me that my issue is a known problem and I can expect a subsequent update.  They have not offered any workarounds yet.


    walter fink

    Friday, January 9, 2015 8:36 PM
  • Hi Walter Fink,

    Yes, Microsoft confirmed it as an known issue here:

    https://connect.microsoft.com/VisualStudio/feedback/details/1074829/vs2013-wp8-build-error-the-name-initializecomponent-does-not-exist-in-the-current-context-in-my-app-xaml-cs-page

    Let's wait some workarounds or fix on this issue.

    Thanks,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, January 12, 2015 6:03 AM