开发者

How do you fix schema / namespace error in Visual Studio 2010? (WPF / XAML)

开发者 https://www.devze.com 2023-01-28 08:46 出处:网络
I\'m not sure why, but latel开发者_运维百科y Visual Studio cannot seem to find the schema used in XAML on the root Window.

I'm not sure why, but latel开发者_运维百科y Visual Studio cannot seem to find the schema used in XAML on the root Window.

This is the error message I'm getting:

Message 1 Could not find schema information for the element 'http://schemas.microsoft.com/winfx/2006/xaml/presentation:Window'.

The error results in IntelliSense not working. However, the project still compiles and runs as expected. The problem is the same in every project I open. Starting on a new project gives me the following XAML:

<Window x:Class="WpfApplication2.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>

    </Grid>
</Window>

But I'm getting the same error.

I've tried, without luck, all of the following:

  • Reinstalling Visual Studio 2010
  • Reinstalling .NET
  • Removing the Visual Studio directory (\Users\[User]\Documents\Visual Studio 2010).

What do I do to fix it?


This was happening for me because I had configured Visual Studio to open XAML files in the XML (Text) Editor.

To fix the problem, right click on a XAML file in the Solution Explorer, chose "Open With", select "Automatic Editor Selector" and click "Set as Default".

If you want to open XAML documents in full XAML view, go to Tools -> Options -> Text Editor -> XAML -> Miscellaneous and check "Always open documents in full XAML view".


What is the TargetFramework version, is it ".Net Framework 4" or ".Net Framework 4 Client Profile". If it is Client Profile, change it to ".Net Framework 4", you may have one more luck.


You can also get this error if you opened an xaml file that is not included in the project, as it opens by default in the text editor. Then added it to the project. I fixed by closing the project and re-opening.

0

精彩评论

暂无评论...
验证码 换一张
取 消