Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assembly reference not found in XAML, but code compiles when referenced in xaml.cs class

Tags:

c#

.net

wpf

xaml

mdi

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> in the XAML, 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".

This is my XAML:

<Window x:Class="QueryBuilder.Table"
        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"
        Height="300" Width="300" WindowStyle="ToolWindow" ResizeMode="NoResize" ShowInTaskbar="False">
</Window>

This problem has been frustrating me all day. I've tried almost everything imaginable. One thing worth noticing is that I've downlaoded the sample application from the library's site, and I can run it with no problems. Besides this, I have added this to the xaml.cs class of my project: WPF.MDI.MdiContainer d = new WPF.MDI.MdiContainer(); and it compiles with no problems at all.

Please also note that my initial problem was asked here, and none of the suggestions worked. The problem has now changed however, due to the above paragraph which seems to indicate that the code is compiled successfully in the code behind, but not in the XAML file.

EDIT: I would also like to add that I am able to browse through the code of the assembly reference as shown below.

enter image description here

like image 753
Dot NET Avatar asked Oct 14 '12 18:10

Dot NET


2 Answers

I've finally solved the problem myself - going to leave this answer here incase someone has the same problem some time. Adding the solution itself to the reference path of the assembly solves the problem! It's a shame this isn't documented...

EDIT: To clarify, what I did was add the solution, rather than the dll. In other words, I added the MDI solution with all its classes. This naturally applies to DLLs where the source code is available too.

like image 157
Dot NET Avatar answered Oct 22 '22 16:10

Dot NET


If Visual Studio keeps complaining and underlining even after you tried everything, terminate the XDesProc.exe process using Task Manager and then rebuild the solution.

like image 20
Ondřej Avatar answered Oct 22 '22 15:10

Ondřej