wpf 添加dll引用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12884408/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Adding dll reference
提问by Dot NET
I've got a strange problem adding a dll reference. I've got a WPF application and am trying to use the WPF MDI library: http://wpfmdi.codeplex.com/
我在添加 dll 引用时遇到了一个奇怪的问题。我有一个 WPF 应用程序,正在尝试使用 WPF MDI 库:http: //wpfmdi.codeplex.com/
As stated in the instructions (which are very vague), I right-clicked on references in VS2012, clicked on Add reference.., clicked on Browse..and added my dll which I downloaded.
如说明中所述(非常模糊),我在 VS2012 中右键单击引用,单击Add reference..,单击Browse..并添加我下载的 dll。
Next, I added the following line in the XAML of my window: xmlns:mdi="clr-namespace:WPF.MDI;assembly=WPF.MDI"as stated in the instructions.
接下来,我在窗口的 XAML 中添加了以下行:xmlns:mdi="clr-namespace:WPF.MDI;assembly=WPF.MDI"如说明中所述。
However, when trying to add an <mdi:MdiContainer>, the following error messages are displayed:
但是,在尝试添加 时<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 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".
The name "MdiContainer" does not exist in the namespace "clr-namespace:WPF.MDI;assembly=WPF.MDI".
Any ideas?
有任何想法吗?
EDIT:
编辑:
Added my XAML file
添加了我的 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>
回答by jags
The project at MDI Projectseems to use .Net 4 Client Profile. Just make sure the WPF.MDI project has been compiled using .Net Framework 4 runtime.
在该项目的MDI项目似乎使用.NET 4的客户端配置文件。只需确保已使用 .Net Framework 4 运行时编译 WPF.MDI 项目。
回答by Furqan Safdar
Check .NET Framework settings of your project. Make sure it is not set to .NET Framework Client Profile. Because as per my experience this error usually appears when there is a mismatch in the framework settings. Hope this helps!
检查项目的 .NET Framework 设置。确保它没有设置为.NET Framework Client Profile。因为根据我的经验,当框架设置不匹配时,通常会出现此错误。希望这可以帮助!
回答by Brian Cook
Download the source for the DLL from the MDI Project. Recompile to current .net version and then re-add as a reference and recompile your project.
从MDI 项目下载 DLL 的源代码。重新编译到当前的 .net 版本,然后重新添加为参考并重新编译您的项目。

