LayoutAwarePage does not exist in namespace VS2012 bug?
Asked Answered
B

10

22

I'm trying to get a search contract working on my Win 8 app but after adding a search contract to my project I get the following namespace error:

LayoutAwarePage does not exist in namespace App1.Common.

I do have the correct namespace declarations in the xaml:

xmlns:common="using:App1.Common"

and the LayoutAwarePage is in the correct namespace App1.Common

Restarting VS2012 or doing a delete and rebuild doesn't help. To replicate this problem try the following:

1) create new blank metro app

2) add references to Visual C++ runtime

3) add a search contract to the project (click Yes to automatically add other stuff like LayoutAwarePage etc)

4) rebuild and open SearchResultsPage1.xaml

If you follow the above steps you should see the error and also note that the SearchResultsPage1 does not display in the designer.

This problem only occurs when you add the reference to the Visual C++ runtime. Without this reference adding a search contract works fine!

Any ideas? What am I missing here? Can you replicate the issue using the above steps?

Ballet answered 13/9, 2012 at 7:29 Comment(6)
Does this #11005310 help you ?Autopilot
It seems that it is the same issue, but at this moment I'm struggling to understand what I need to do to fix it - my default namespace is simply App1. I'll look at that answer again....Ballet
Nope, I'm still struggling to understand how to fix it. Renaming the winmd file to App1.winmd didn't work...Ballet
I'm running into this same issue as well. It seems that when I change the project's target CPU to x86 it works OK. Using x64 or ARM I receive the same error.Safford
Did you ever fix this? I have the same issue #13462441Budbudapest
@JoshRickard - this solved my problem as well, still no idea why.Folsom
M
27

I just ran into the same issue.

Closing VS and deleting the relevant SUO file (in the folder of the solution, may be hidden) worked like a charm.

Mortician answered 24/9, 2012 at 15:21 Comment(2)
Once I deleted the solution options file (I'm guessing the .SUO file mentioned above), I no longer got the error and the project built. This file was hidden as mentioned above.Melanesian
Worked Wonders. Google Search is just a pipeline that connects to a StackOverflow link. Any weird bug just Google the full text!Bedizen
S
12

You must add a reference to the WinRTXamlToolkit: From VS2012 Express

  1. Right click on the "References" item;
  2. Select "Manage NuGet Packages...";
  3. In the menu on the left in the new window select "Online" then "Windows & Packages";
  4. Search for the library named "WinRTXamlToolkit", select it then click on the "Install" button.
Strath answered 30/10, 2012 at 17:6 Comment(3)
Can you elaborate on why this fixes the issue?Safford
Thank you for this answer. Although, it didn't resolve my issue entirely I think this and deleting the .suo file mentioned in a different answer resolved my issue.Melanesian
It contains helper classes and other required Helpers for Xaml.Treasonable
L
6

Please close all tabs in VS if opened.

Then Click Build-> clean solution

next click build->rebuild solution

Now open the xaml file.

Hope it will work

Lechery answered 20/4, 2013 at 11:14 Comment(0)
U
3

For me this infuriating bug was solved by simply changing from Debug Any CPU to x86 and even with the designer open it sprang back into life. Then when you are done you can close and change back to Any CPU and build just fine.

Undistinguished answered 24/5, 2014 at 21:1 Comment(0)
T
1

I removed the reference to the Bing Maps SDK and set the Platform Target back to Any CPU and it solved the problem for me.

Toscano answered 29/9, 2012 at 3:8 Comment(1)
Trouble is that I am using Bing Maps SDK (which is dependant on the Visual C++ library)Ballet
K
1

I had this nagging problem which may have been linked to using the SQLite for Windows RT add on (v3.7.15), and random "Design view is unavailable for x64 and ARM target platforms" errors.

Regardless, for me, everything works fine now, including the layout aware functionality, once I changed the target platform to x86 for both the project AND solution.

So right click both the project and solution in Solution Explorer, click Properties, and select an x86 architecture.

It does make me a bit nervous to not have "Any CPU" as the target, so if anyone knows how to make this work with SQLite and layout aware pages, please chime in.

Kenwood answered 18/12, 2012 at 20:39 Comment(0)
D
1

Close all the xaml file and rebuild the project. If you have errors in the cs files fix them first. For me it was easy as adding public static MainPage Current; to the mainpage.

Deannadeanne answered 18/2, 2013 at 14:37 Comment(0)
M
1

I just unloaded the project and reloaded it in VS'2012 and it started working. No deleting anything necessary.

Merritt answered 2/3, 2013 at 18:55 Comment(1)
thanks, this has worked for me too. But is it visual studio bug or what? Because i have created new project and added Basic page to it and it automatically created required files, but then after rebuilding it as well this does not fix..Bureaucrat
C
0

I got a long list of similar bugs when compiling an UWP app. Hidden among them however, were several genuine compile errors. When I fixed the genuine errors, the missing references also disappeared.

So, fix any other compile errors first, and see if these "missing in namespace" errors then disappear.

EDIT: My colleague also had this bug in VS 2017. Cleaning the solution via the Build menu didn't work. Right-clicking on the projects in the Solution Explorer and cleaning each one, then re-building, worked.

EDIT2: Just had this problem again. 22 "missing in namespace" errors.
I had deleted a button handler from a ViewModel, but forgotten to delete the button from the XAML code. When I fixed this genuine error, the 22 "missing in namespace" errors also disappeared.

Callable answered 21/7, 2017 at 13:11 Comment(0)
A
-1

I also have the same issue in Visual Studio 2012 while adding new basic page in Xaml.I just run my application and the error removed automatically.

Almanza answered 20/11, 2018 at 17:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.