LayoutAwarePage does not exist in namespace VS2012 bug?

青春壹個敷衍的年華 提交于 2019-12-04 08:31:20

问题


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?


回答1:


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.




回答2:


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.



回答3:


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




回答4:


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.




回答5:


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.




回答6:


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.




回答7:


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.




回答8:


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




回答9:


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.




回答10:


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.



来源:https://stackoverflow.com/questions/12401440/layoutawarepage-does-not-exist-in-namespace-vs2012-bug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!