Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
265 views
in Technique[技术] by (71.8m points)

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...