【发布时间】:2016-02-23 18:40:14
【问题描述】:
为了提前弄清楚这一点,我很清楚由于声明中缺少程序集名称而导致的有关此错误的大量问题和答案,此处并非如此。
在过去的几天里,我看到一些非常严重的不稳定性,代码似乎本身会停止编译抛出不真实的错误,然后在关闭然后重新打开 VS 后神奇地再次开始工作,还有我的自定义控件停止出现在设计器中并在 ctor() 中吐出幻像错误,然后修复自己,我的控件中的依赖属性从 VS 属性资源管理器中丢失,但仍然可以从 XAML 访问......我想知道我是否可能会出现某种形式VS 中的 bug,之前我发现 VS 中的 bug 导致我的 g.cs 文件损坏...
严重性代码描述项目文件行抑制状态 错误类型引用找不到名为的类型 '{clr-namespace:ODIF;assembly=PluginInterface}Global'。 CustomControls_WinX86 xxxxxxxxx\CustomControls_WinX86\ChannelBoxMenu.xaml 17
我的用户控件的完整 XAML:
UserControl x:Name="ChannelBoxMenuControl" x:Class="CustomControls_WinX86.ChannelBoxMenu"
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"
xmlns:local="clr-namespace:CustomControls_WinX86"
xmlns:ODIF="clr-namespace:ODIF;assembly=PluginInterface"
mc:Ignorable="d"
d:DesignHeight="100" d:DesignWidth="250">
<Grid>
<Menu x:Name="menu">
<MenuItem x:Name="menuItem" BorderThickness="0" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Template="{DynamicResource MarginlessMenuItem}" Width="{Binding ActualWidth, ElementName=menu, Mode=OneWay}" Height="{Binding ActualHeight, ElementName=menu, Mode=OneWay}" >
<MenuItem.Header>
<local:ChannelBox Width="{Binding ActualWidth, ElementName=menuItem, Mode=OneWay}" Height="{Binding ActualHeight, ElementName=menuItem, Mode=OneWay}" Channel="{Binding SelectedChannel, ElementName=ChannelBoxMenuControl}"/>
</MenuItem.Header>
<MenuItem.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Source={x:Static ODIF:Global.ConnectedDevices}, Mode=OneWay}"><!--THIS IS WHERE THE ERROR IS THROWN-->
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
<Image Source="{Binding StatusIcon}" Width="16" Height="16">
<Image.Style>
<Style TargetType="{x:Type Image}">
<Style.Triggers>
<DataTrigger Binding="{Binding Icon}" Value="{x:Null}">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
<TextBlock Text="{Binding DeviceName}"/>
</StackPanel>
</HierarchicalDataTemplate>
</MenuItem.ItemTemplate>
</MenuItem>
</Menu>
</Grid>
</UserControl>
以及我引用的程序集中的相关代码:
namespace ODIF
{
public static class Global
{
internal static GlobalStore Store = new GlobalStore();
public static AsyncObservableCollection<InputDevice> ConnectedDevices
{
get
{
return Store.inputDevices;
}
}
}
internal class GlobalStore
{
internal AsyncObservableCollection<InputDevice> inputDevices;
}
}
另外值得注意的是,当我开始输入 HierarchicalDataTemplate ItemsSource 的路径时,智能感知会很好地选择路径 ODIF:Global.ConnectedDevices 并自动完成它,但随后会抛出找不到它的错误... .
【问题讨论】:
-
听起来像是 VS 的损坏安装。您是否尝试过重新安装?
-
在厌倦了我提到的其他问题后,今天早上刚刚更新到 2015.1,尽管在最近一轮错误之前一切都很好。似乎可能需要完全卸载并重新安装,但这需要很长时间。
-
当然,有人通过投票来推动而不费心阅读这与其他有关此错误的问题不同的事实。