简体   繁体   English

命名空间中不存在类型或命名空间名称 - 没有引用

[英]The type or namespace name does not exist in the namespace - without reference

I encountered a strange problem (Visual Studio 2012):我遇到了一个奇怪的问题(Visual Studio 2012):

"The type or namespace name 'X' does not exist in the namespace 'XX.X' (are you missing an assembly reference?) ...\\MyUserControl.g.cs .... “命名空间 'XX.X' 中不存在类型或命名空间名称 'X'(您是否缺少程序集引用?)...\\MyUserControl.g.cs ....

I have the following user control:我有以下用户控件:

<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>

and when I try to build the project the .g.cs file insists to add namespace that does not exist in references, and do not use it in any way in xaml.当我尝试构建项目时, .g.cs文件坚持添加引用中不存在的命名空间,并且不在 xaml 中以任何方式使用它。

I tried to make a clean and rebuild.. nothing helps.我试图进行清理和重建。没有任何帮助。

Usually such problems are when the namespace is not written correctly, but here I have no reference to any other namespace, so it is strange.通常这样的问题是在命名空间没有正确写入时,但这里我没有引用任何其他命名空间,所以很奇怪。

Anyone else having this problem and can help?还有其他人遇到这个问题并且可以提供帮助吗?

Mat 的评论帮助我解决了这个问题:我在Generic.xaml找到了参考。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 类型或名称空间名称在名称空间中不存在“是否缺少程序集引用?” - The type or namespace name does not exist in the namespace ''are you missing an assembly reference ?" 命名空间中不存在类型或命名空间名称(您是否缺少程序集引用?) - The type or namespace name does not exist in the namespace (are you missing an assembly reference?) 类型或名称空间名称在名称空间中不存在 - The type or namespace name does not exist in the namespace 名称空间中不存在类型或命名空间名称“GetName” - The type or namespace name 'GetName' does not exist in the namespace 类型或名称空间名称“ MIDI”在名称空间中不存在 - The type or namespace name 'MIDI' does not exist in the namespace 命名空间中不存在类型或命名空间名称“Linq” - The type or namespace name 'Linq' does not exist in the namespace 命名空间中不存在类型或命名空间名称“Exchange” - The type or namespace name 'Exchange' does not exist in the namespace 类型或名称空间名称“ Confidence”在名称空间中不存在 - The type or namespace name 'Confidence' does not exist in the namespace 命名空间中不存在类型或命名空间名称 - type or namespace name does not exist in the namespace 命名空间中不存在类型或命名空间名称“优化” - The type or namespace name 'Optimization' does not exist in the namespace
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM