This post is a clarification of the preceding post.
If you try to load XAML file at runtime with the XamlReader it is important that you specify the full assembly if the file contain reference to local defined object. As an example, if I use a custom IValueConverter defined in my assembly, the cyder designer can generate such a XAML file for a resource
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:UILogic="clr-namespace:Proximo.Planner.Gui.Presentation.UILogic">
IF the code gets compiled into the assembly all went good, but when you try to compile with XamlReader.Load() an exception of type XamlParseException is raised with such a message “Missing XmlNamespace, Assembly, or ClrNamespace in Mapping instruction. Line ’3′ Position ’5′.”
You have to specfy the assembly where the UILogic namespace live. You can try
xmlns:UILogic=”clr-namespace:Proximo.Planner.Gui.Presentation.UILogic, Proximo.Planner.Gui“>
But the error is still there, you cannot use the standard syntax to define a type in .net, because in XAML the story is a little bit different, here is the correct way to declare a custom namespace in XAML file that has to be loaded runtime.
xmlns:UILogic=”clr-namespace:Proximo.Planner.Gui.Presentation.UILogic;assembly=Proximo.Planner.Gui“>
Now the file can be loaded successfully
Alk.
Tags: XamlReader
Tags: Uncategorized






May 22nd, 2008 at 6:40 pm
Thank you for sharing this! It really helped me in the case where one RD in one project was merging-in another RD in another project in the same VS solution. Since the RD being merged-in had an xmlns defined that didn’t have the assembly explicitly stated, that same “Missing XmlNamespace, Assembly, or ClrNamespace in Mapping instruction” exception was thrown. Added the assembly specification fixed it!
March 3rd, 2009 at 9:02 am
Thx a lot!!! I’m new to WPF and its been a very bad day… I nearly went into panic mode when i saw that error…
January 8th, 2010 at 5:40 pm
Thanks, You just saved me countless hours.