2

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>
Dot NET
  • 4,891
  • 13
  • 55
  • 98
  • Did you set the reference to copy local? Pretty sure you need to for the namespace to resolve. – iivel Oct 14 '12 at 16:58
  • 1
    Check the DLL reference, Copy to Local should be true. And try building the project once before adding any reference in XAML file. – jags Oct 14 '12 at 16:58
  • Tried that too, still no luck :/ – Dot NET Oct 14 '12 at 17:01
  • I've edited the question to show the error messages I'm receiving – Dot NET Oct 14 '12 at 17:05
  • just curious, are you able to see the WPF.MDI namespace in codebehind file and use it. I mean try accessing the type once from WPF.MDI namespace in code behind instead of trying in XAML and see if the namespace and type are visible and project gets compiled or not? – jags Oct 14 '12 at 17:19
  • Could you kindly explain where I can find this please? All I added to the project is the dll – Dot NET Oct 14 '12 at 17:34
  • I'm wondering if I'm doing something wrong - do I have to add the project too? All I've added is the dll – Dot NET Oct 14 '12 at 17:45
  • I've added the project to the solution and the problem is still here – Dot NET Oct 14 '12 at 18:01

3 Answers3

3

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.

jags
  • 2,022
  • 26
  • 34
  • I'm wondering if I'm doing something wrong - do I have to add the project too? All I've added is the dll – Dot NET Oct 14 '12 at 17:44
  • I've added the project to the solution and the problem is still here – Dot NET Oct 14 '12 at 18:02
  • Just for a simple test, create a new Console Application project, add the reference to WPF.MDI DLL and access the MdiContainer type in Main method. If the code compiles then WPF application code should compile too. Just make sure Console Application project uses the same runtime version as of WPF.MDI DLL. You can check the WPF.MDI DLL's CLR version using ILDASM command. – jags Oct 14 '12 at 18:18
  • I've tried something similar - I went into the xaml.cs class and created an `WPF.MDI.MdiContainer` object. This worked, however I still cannot seem to create one in the XAML – Dot NET Oct 14 '12 at 18:25
  • Thanks for the help, but I'm still out of luck. I'll try asking a new question based on the new details, since the situation has fundamentally changed since the code compiles in the cs file. – Dot NET Oct 14 '12 at 18:48
1

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!

Furqan Safdar
  • 16,260
  • 13
  • 59
  • 93
0

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.

Brian Cook
  • 37
  • 2
  • 2
  • 10