Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 命名空间中不存在类型或命名空间名称-无引用_C#_Wpf_Visual Studio_Namespaces - Fatal编程技术网

C# 命名空间中不存在类型或命名空间名称-无引用

C# 命名空间中不存在类型或命名空间名称-无引用,c#,wpf,visual-studio,namespaces,C#,Wpf,Visual Studio,Namespaces,我遇到了一个奇怪的问题(Visual Studio 2012): “命名空间'XX.X'中不存在类型或命名空间名称'X'(是否缺少程序集引用?)…\MyUserControl.g.cs 我有以下用户控件: <UserControl x:Class="xxxxxx.MyUserControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x=

我遇到了一个奇怪的问题(Visual Studio 2012):

“命名空间'XX.X'中不存在类型或命名空间名称'X'(是否缺少程序集引用?)…\MyUserControl.g.cs

我有以下用户控件:

<UserControl x:Class="xxxxxx.MyUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <StackPanel>
        <TextBlock Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, Path=h}" FontWeight="Bold" FontSize="12" Foreground="Black" />
        <TextBlock Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, Path=hd}" FontSize="12" Margin="10,10,0,5" MaxWidth="250" TextWrapping="Wrap" Height="Auto" Foreground="Black"/>
    </StackPanel>
</UserControl>

当我尝试构建项目时,.g.cs文件坚持添加引用中不存在的名称空间,并且在xaml中不以任何方式使用它

我试图做一个清洁和重建…没有任何帮助

通常这样的问题发生在名称空间编写不正确的时候,但这里我没有引用任何其他名称空间,所以很奇怪


还有谁有这个问题并能提供帮助吗?

帮助我解决了这个问题:我在
Generic.xaml

中找到了引用。尝试将UserControl的内容复制到剪贴板,删除UserControl,创建一个新的UserControl,然后从剪贴板中粘贴内容。对任何隐藏的代码执行相同的操作。然后关闭.g.cs文件。并重新生成。@mm8我尝试过,也没有帮助:(您应该检查您的XAML中是否定义了引用此无法识别的程序集的命名空间。在我看来,您的XAML代码非常完美。只需做一件事,创建一个新项目并尝试重新构建它,可能它位于“style.XAML”或“Generic.XAML”中。您尝试过“在文件中查找”吗?