Unable to create xmlns link for another project in XAML

I have a WPF project defined as follows:

  Myapp.sln
   Myapppppf
   MyApp.Domain

In one of my xaml files in the MyAppWPF project, I am trying to reference the class defined in the MyApp.Domain project. I have a link to a project in MyAppWPF on MyApp.Domain. I am trying to create a link as follows:

  <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 a message that the assembly was not found, but I can create an instance of the class that I want to reference in the code behind, so I know that I named it correctly.

How can I do it? Do I need a strong name or link to the dll directly instead of the link to the project?

+4
source share
5 answers

Check if

  • MyClass full name is MyApp.Domain.MyClass
  • MyClass has a public default constructor (without parameters) so that XAML can create it.
+2
source

Can there be any help?

Visual Studio 2008 (RTM) WPF Designer Cannot Load Assembly or Dependency

I assume that you are using Visual Studio 2008. If you are using Visual Studio 2005, this is a known issue in the XAML design, code-named "Cider," which is included in "Visual Studio 2005 Extensions for WPF and WCF."

+1
source

You only need to set assembly=MyApp.Domain if you are dynamically compiling XAML.

If you just created your XAML once, exclude this token and just say xmlns:local="clr-namespace:MyApp.Domain" .

+1
source

If XAML is not free (compiled in assembly (DLL / EXE)
make sure the assembly has a link to the assembly you are looking for
(right click on the project → add link ...).

If XAML is free, make sure that the assembly it is looking for is copied to the same directory from which exe is launched.

0
source

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

 xmlns:local="clr-namespace:YourProjectNameSpace;assembly=" 
0
source

All Articles