locked
'LayoutAwarePage" does not exist in the namespace "using:AppName.Common -How do I get rid of this?

    Question

  • I am not sure this problem is related to the selection of the platform or any configuration . I am on Win32 for a C++ project and never changed any configurations.

    I am seeing the same problem in all of my XAML files (all generated by the template) with the error messages

    The name "LayoutAwarePage" does not exist in the namespace "using:AppName.Common"

    and

    The member "Resources" is not recognized or is not accessible

    for the line containing

    <Page.Resources>

    The automatically created LayoutAwarePage.h which is #included in the XAML has the standard preamble

    namespace AppName
    {
        namespace Common
        {
            [Windows::Foundation::Metadata::WebHostHidden]
            public ref class LayoutAwarePage : Windows::UI::Xaml::Controls::Page
            {

    This looks like a simple symbol table bug unrelated to any configuration

    Binging brings up a lot of reports of this with the only solution proposed to close all XAML files and rebuild the solution and restart VS2012. This doesn't work for me. I just cannot get rid of those error messages which means Designer and properties panel doesn't work for any XAML file using LayoutAwarePage.

    I found a bug report filed on this but it is closed as being by design with a work around to rebuild the project! Brilliant.

    Can Microsoft folks confirm if this is a known problem and if there is a workaround or if there is an bug fix service pack planned for VS2012.

    Given how buggy this program is, a bug fix service pack before introducing more features would be very welcome. Thanks.

    Monday, November 19, 2012 9:55 AM

All replies

  • PS: The project compiles fine and runs with no errors. It is an XAML editor/designer problem.

    Opening the project in Blend has the same problem.

    Monday, November 19, 2012 9:59 AM
  • I can reproduce this by simply creating a new project using the Windows Store Grid App template for C++ and opening the generated GroupDetailPage.xaml as soon as the project is created without doing anything else. If I close the xaml file and rebuild the solution and open that XAML file, the errors go away. But, in my case, once I started making changes to it, the errors came back (not sure which changes triggered this) and does not go away with rebuilding, restarts, closing and opening the XAML files, etc.

    But the reproducibility as above before the build should let you figure out why this error happens and see under what conditions that error will happen again that rebuilding does not help (or there is a bug in rebuilding).

    Monday, November 19, 2012 10:13 AM
  • Hi there,

    I would be more than happen to investigate this issue. Could you please get in touch with me directly at unnir at Microsoft dot com, as we will likely have to debug this issue on your machine?

    Thanks,
    Unni


    Unni Ravindranathan, Program Manager, Visual Studio and Blend This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, November 21, 2012 2:40 AM
  • I have had this problem twice now. I managed to get around it both times, but it's clearly a terrible bug that can really screw up a project.

    The simplest workaround was to simply recreate the project file by file (i.e. create a blank project and recreate every file via copy and pasting the text). This works but is tedious and will take a while on a big project.

    The second time this happened (on the project I had painstakingly recreated file by file...) I found some blue squiggly lines in my XAML for the last page I had worked on. Now the XAML was perfectly correct, but for some reason VS had decided it was no longer valid (despite not being changed at all since the project compiled last). I found that by moving this bit of XAML the blue squigglies disappeared and so did the ~100 errors that I had.

    I fully expect this to keep happening until Microsoft discover and/or correct the bug.

    Sunday, December 02, 2012 8:30 AM
  • Thanks for reporting this issue. When you get into this state next time. Can you please get the dump of the XdesProc & Blend\VS exe and send it to me. You can contact me directly at harikm@microsoft.com.

    Dev@Mic

    Wednesday, December 05, 2012 2:22 AM
  • No need for dump.

    This is a customer wide problem, that happens when a developer's namespace conflicts with the "Default" one. A workaround is proposed in this thread

    http://social.msdn.microsoft.com/Forums/is/winappswithcsharp/thread/a24844bf-058f-40e3-8b2b-b2033a4abeb8

    Basically, In App.xaml.h,

    Place this before the namespace created for the project (eg: "namespace App2 {...." for  a project named "App2"):

    namespace nnn
     {
     public ref class ccc sealed
     {
     };
     }

    And build, it'll cause the same error to happen. If you comment out this code, the error goes away. Clearly a namespace conflict and this should be fixed asap.

    Thanks


    Unfortunately this is not the answer. It solves a problem with a similar symptom, but doesn't solve this error in some instances. I have had this error several times now, and this fixed it once, but not on subsequent errors.

    The only full workaround I have found is to recreate the solution file-by-file. Specifically: I can copy and paste all the code into a new solution and it works. This implies strongly that there is nothing wrong with the code itself, either in the XAML or the vb/c# code, but something both fundamental and outside of the user's control.

    Also: in the times this has happened to me, it has been spontaneous and not directly attributable to anything changed in my code. e.g. changing an arbitrary control in XAML has suddenly resulted in 100+ XAML errors stemming from the LayoutAwarePage issue. Undoing the change (or removing the changed item) has no effect, and nor does closing/re-opening the solution without saving.

    Friday, December 07, 2012 1:50 AM
  • I have found the bug in my very own code base -.-.

    Specifically, I was passing an std::vector::iter pointer to a function expecting wstring pointer, amongst other culprits. Fixing this made my application work!

    Try to scan your codebase for changes made around the time your project stopped displaying the xaml page.  

    • Proposed as answer by navits - MSFT Wednesday, December 19, 2012 7:01 PM
    Wednesday, December 12, 2012 5:01 PM
  • Try to scan your codebase for changes made around the time your project stopped displaying the xaml page.  

    Unfortunately this is only one potential cause of the error, and not the cause that is the main issue.

    The error occurs spontaneously (i.e. without any change to code), and considering that copying and pasting every line of code into a new solution fixes the issue, it can't (always) be a problem with the code itself.

    There is either a bug in VS2012 or some bizarre, untraceable, unknowable mistake being made by myself and others to get this error. It thankfully hasn't happened again to me in several weeks, so perhaps it has been fixed in one of the recent updates.

    Wednesday, December 19, 2012 11:38 PM
  • I've exactly the same problem and it's really annoying. I only moved "LayoutAwarePage" to an other namespace and changed it everywhere (cs AND xaml) - compiling works perfect - but the designer says it's not in that namespace. Same for "StandardStyles.xaml": I moved it to an other firectory, but changed it in the "App.xaml" file. Compiling, again, works fine - but none of the xaml files can be opened without the error of the style not being found.

    I'M running Visual Studio 2012 Professional Update 1 on Windows 8 Pro x64. Thank you very much!

    Monday, December 31, 2012 2:22 PM
  • If this is a consistent repro, can you please zip your project and share it out so we can investigate?

    Thanks!


    Unni Ravindranathan, Program Manager, Visual Studio and Blend This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, January 02, 2013 8:55 PM
  • If this is a consistent repro, can you please zip your project and share it out so we can investigate?

    Thanks!


    Unni Ravindranathan, Program Manager, Visual Studio and Blend This posting is provided "AS IS" with no warranties, and confers no rights.

    Fortunately I haven't had this issue for a while. Perhaps it has been addressed in a recent update.

    My suspicion (not that I have any idea how VS2012 works internally) is that something quite arbitrary causes the issue, and VS for some reason doesn't recognise that there is nothing wrong with the project. It's as if a flag has been marked 'broken' when in fact nothing is amiss, but the flag can't be reset.

    • Proposed as answer by Bill_Spaulding Tuesday, January 22, 2013 4:53 AM
    • Unproposed as answer by Bill_Spaulding Tuesday, January 22, 2013 4:53 AM
    Thursday, January 03, 2013 4:00 AM