C# &引用;命名空间中不存在“0”;XAML名称空间错误

C# &引用;命名空间中不存在“0”;XAML名称空间错误,c#,wpf,visual-studio,xaml,visual-studio-2012,C#,Wpf,Visual Studio,Xaml,Visual Studio 2012,对我来说,这是一个偶然的、反复出现的问题。我将对我的项目进行任意更改,反过来VisualStudio将给我96个名称空间错误。我的XAML名称空间声明几乎总是错误的,但我知道这些类存在于名称空间中 我已经清理和建设,重建了很多次,以及重新启动VS没有成功 示例: 在本例中,类ExpandedConverter在名称空间clr namespace:NineGridViewer中“不存在”。一个可能的问题是,我已经将我的项目组织到文件夹中,例如,转换器都在IValueConverters文件夹中,M

对我来说,这是一个偶然的、反复出现的问题。我将对我的项目进行任意更改,反过来VisualStudio将给我96个名称空间错误。我的XAML名称空间声明几乎总是错误的,但我知道这些类存在于名称空间中

我已经清理和建设,重建了很多次,以及重新启动VS没有成功

示例:

在本例中,类ExpandedConverter在名称空间clr namespace:NineGridViewer中“不存在”。一个可能的问题是,我已经将我的项目组织到文件夹中,例如,转换器都在IValueConverters文件夹中,MainWindow在Views文件夹中。但是名称空间没有改变


名称空间NineGridViewer{
/// 
///将UI扩展器的isExpanded属性绑定到ViewModel的CurrentExpanded属性
/// 
公共类ExpandedConverter:IValueConverter
{
公共对象转换(对象值、System.Type targetType、对象参数、System.Globalization.CultureInfo区域性)
{
字符串输入=作为字符串的值;
string param=作为字符串的参数;
if(String.IsNullOrEmpty(输入)| | String.IsNullOrEmpty(参数))
{
抛出新ArgumentNullException();
}
返回等于(输入,参数);
}
公共对象转换回(对象值、System.Type targetType、对象参数、System.Globalization.CultureInfo区域性)
{
返回参数;
}
}
}

编译错误正在阻止生成程序集,因此Visual Studio无法检查它们并在XAML设计器和其他工具中使用它们

这就是为什么会出现这些看似缺失的类错误


应该有一个“root”错误(通常在列表的底部),这是一个真正的编译错误。如果修复了此问题,则所有其他错误都应在生成时消失。

如果未生成解决方案,则会出现此错误,因为XAML设计器找不到这些类。只要重建,错误就会消失。请检查:在我的情况下,解决方案是删除我的存储库(意味着所有项目文件)并再次克隆它。通过这种方式,您可以确保即使是那些被git忽略的文件也会被删除。这很有意义。在这种情况下,根错误似乎是因为我的测试项目中缺少元数据文件,对吗?(错误截图是我所有的错误)。我清理/重建了我的测试项目,这似乎是根错误的来源。谢谢
<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:nineGridViewer="clr-namespace:NineGridViewer"
    Title="NineGridViewer" Height="900" Width="900">
   <Window.Resources>
      <nineGridViewer:ExpandedConverter x:Key="ExpandedConverter"/>
      <nineGridViewer:StringToBrushConverter x:Key="StringToBrushConverter"/>
   </Window.Resources>
namespace NineGridViewer {
/// <summary>
/// Binds the isExpanded property of the UI Expanders to the ViewModel's CurrentExpanded property
/// </summary>
public class ExpandedConverter : IValueConverter
{
    public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        string input = value as string;
        string param = parameter as string;
        if (String.IsNullOrEmpty(input) || String.IsNullOrEmpty(param))
        {
            throw new ArgumentNullException();
        }
        return Equals(input, param);
    }

    public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        return parameter;
    }
}
}