![](/img/trans.png)
[英]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 - without reference
我遇到了一個奇怪的問題(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 中以任何方式使用它。
我試圖進行清理和重建。沒有任何幫助。
通常這樣的問題是在命名空間沒有正確寫入時,但這里我沒有引用任何其他命名空間,所以很奇怪。
還有其他人遇到這個問題並且可以提供幫助嗎?
Mat 的評論幫助我解決了這個問題:我在Generic.xaml
找到了參考。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.