Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6864757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:57:09+00:00 2026-05-27T02:57:09+00:00

I have a WPF project with an AssemblyInfo.cs that groups multiple CLR namespaces into

  • 0

I have a WPF project with an AssemblyInfo.cs that groups multiple CLR namespaces into a single XML namespace:

[assembly: XmlnsDefinition("http://foo.bar", "MyLibary.Controls")]
[assembly: XmlnsDefinition("http://foo.bar", "MyLibary.Converters")]

In XAML this is used like so:

<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:fb="http://foo.bar">
    <fb:FooButton IsEnabled="{Binding Something, Converter={fb:FooConverter}}"/>
</UserControl>

This works great when the XAML is instantiated normally, but now I am now trying to dynamically load XAML files from my project using XamlReader.

The problem: I can’t seem to map multiple CLR namespaces to a single XML namespace. It seems that the last definition added to the XamlTypeMapper is the only one that persists (e.g. it clobbers previous registrations):

var parserContext = new ParserContext();
parserContext.XmlnsDictionary.Add("x", "http://schemas.microsoft.com/winfx/2006/xaml");
parserContext.XmlnsDictionary.Add("fb", "http://foo.bar");

parserContext.XamlTypeMapper = new XamlTypeMapper(new string[] {"MyLibrary"});
parserContext.XamlTypeMapper.AddMappingProcessingInstruction("http://foo.bar", "MyLibrary.Converters", "MyLibrary");
parserContext.XamlTypeMapper.AddMappingProcessingInstruction("http://foo.bar", "MyLibrary.Controls", "MyLibrary");

...

var rootNode = XamlReader.Load(memeoryStream, parserContext) as FrameworkElement

The error message is:

'Cannot create unknown type '{http://foo.bar}MyConverter'.'

If all put all my code under a single common CLR namespace, everything works but unfortunately this is not option. Has anybody mapped multiple CLR namespaces to a single XML namespace for the purpose of loading XAML content dynamically?

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:57:09+00:00Added an answer on May 27, 2026 at 2:57 am

    As mentioned in the comments above, the solution is to manually load the assembly before invoking XamlReader.Load and removing the type mapper and context all together:

    Assembly.Load("MyLibrary");
    var rootNode = XamlReader.Load(memeoryStream) as FrameworkElement
    

    I would have assumed since the XamlTypeMapper is initialized with a list of assemblies, that this class would be responsible for loading the assembly (and maybe it is) but the behaviour of AddMappingProccessingInstruction prevents this from working.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking into MVVM design patterns with WPF for a project. I
I have a project I'm working on that requires our WPF application read SMS
I have a WPF project (creating dll). The text boxes that added, (or the
I have a WPF C# project that I am working on and I have
I have a WPF project, and there is one dialog that I will re-use
I'm working on a solution where I have a WPF project that is using
I have a WPF Application project with several project references within a single solution
I have the following code that adds a background worker into a VB.net WPF
I have a WPF project where I load a WindowsForsm assembly (dll file) dynamically
We have a WPF Project that follows the MVVM pattern. In the View Model

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.