【发布时间】:2012-10-04 18:21:29
【问题描述】:
我在添加 dll 引用时遇到了一个奇怪的问题。我有一个 WPF 应用程序并正在尝试使用 WPF MDI 库:http://wpfmdi.codeplex.com/
如说明中所述(非常模糊),我右键单击 VS2012 中的引用,单击 Add reference..,单击 Browse.. 并添加我下载的 dll。
接下来,我在窗口的 XAML 中添加了以下行:xmlns:mdi="clr-namespace:WPF.MDI;assembly=WPF.MDI",如说明中所述。
但是,当尝试添加 <mdi:MdiContainer> 时,会显示以下错误消息:
The type 'mdi:MdiContainer' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.
The name "MdiContainer" does not exist in the namespace "clr-namespace:WPF.MDI;assembly=WPF.MDI".
有什么想法吗?
编辑:
添加了我的 XAML 文件
<Window x:Name="..." x:Class="MyClass.MyClass"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mdi="clr-namespace:WPF.MDI;assembly=WPF.MDI"
Title="" WindowState="Maximized">
<Window.Resources>
<Style TargetType="TreeView">
<Setter Property="Padding" Value="0,0,20,0"/>
<Setter Property="BorderBrush" Value="Gray"/>
<Setter Property="BorderThickness" Value="0,0,5,0"/>
</Style>
</Window.Resources>
<mdi:MdiContainer></mdi:MdiContainer>
</Window>
【问题讨论】:
-
您是否将引用设置为复制本地?很确定您需要解析命名空间。
-
检查 DLL 引用,复制到本地应该是真的。并在 XAML 文件中添加任何引用之前尝试构建项目一次。
-
也试过了,还是不行:/
-
我已编辑问题以显示我收到的错误消息
-
只是好奇,您能否在代码隐藏文件中看到 WPF.MDI 命名空间并使用它。我的意思是尝试在后面的代码中从 WPF.MDI 命名空间访问类型一次,而不是在 XAML 中尝试,看看命名空间和类型是否可见并且项目是否被编译?
标签: c# .net wpf dll assemblies