Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't create xmlns reference to other project in XAML

I have a WPF project defined like this:

MyApp.sln
  MyAppWPF
  MyApp.Domain

In one of my xaml files in the MyAppWPF project I'm trying to reference a class defined in MyApp.Domain project. I have a project reference in MyAppWPF to MyApp.Domain. I am trying to create the reference like this:

<Window x:Class="MyAppWPF.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:MyApp.Domain;assembly=MyApp.Domain"
    Title="Window1" Height="305" Width="485">
    <Window.Resources>
       <local:MyClass x:Key="mine" />
    </Window.Resources>
</Window>

I get an error saying the assembly cannot be found, however I can create an instance of the class I want to reference in the code behind, so I know I've got it referenced correctly.

How do I do this? Do I need a strong name, or reference the dll directly instead of using a project reference?

like image 296
Ted Elliott Avatar asked Oct 19 '08 18:10

Ted Elliott


1 Answers

If it helps anyone, I was able to solve my problems by simply adding ;assembly= at the end of the namespace declaration that referred to the containing project itself. For example:

xmlns:local="clr-namespace:YourProjectNameSpace;assembly=" 
like image 90
dotNET Avatar answered Oct 25 '22 09:10

dotNET