Adding dll reference

半城伤御伤魂 提交于 2019-12-22 14:52:21

问题


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/

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.

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.

However, when trying to add an <mdi:MdiContainer>, the following error messages are displayed:

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

Any ideas?

EDIT:

Added my XAML file

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

回答1:


The project at MDI Project seems to use .Net 4 Client Profile. Just make sure the WPF.MDI project has been compiled using .Net Framework 4 runtime.




回答2:


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!




回答3:


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.



来源:https://stackoverflow.com/questions/12884408/adding-dll-reference

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!