Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding a custom namespace to xaml

I am quite new on C#, WPF and XAML, so I may not be able to use the right terms to ask the right question =) I am trying to add my own namespace to my xaml file in order to use my own class easily -I guess the reason is this- I wrote the following code in window tag for this:

xmlns:myns="clr-namespace:LibNameSpace" 

Where my window tag also starts with the following definition:

< Window x:Class="LibNameSpace.MainWindow"

I want to use the LibNameSpace:Class1 class, and I was hoping to write myns:Class1 for this. However, that command causes this error:

Undefined CLR namespace. The 'clr-namespace' URI refers to a namespace 'LibNameSpace' that is not included in the assembly.

How can I fix this?

like image 440
cemregoksu Avatar asked Jul 21 '10 09:07

cemregoksu


1 Answers

The name LibNameSpace sounds like its a library in another assembly. If this is the case, you must add the name of the assembly:

xmlns:myns="clr-namespace:LibNameSpace;assembly=MyLibAssembly

Update:

The name of the assembly can be found in project-explorer in the properties-screen of the project (of the library-assembly). In general also the file-name of the dll without the dll-suffix represents the assembly name.

like image 98
HCL Avatar answered Sep 20 '22 13:09

HCL