Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to reference (in XAML) an assembly with spaces in its name?

Tags:

xaml

Is it not possible to reference an assembly that has spaces in its name? Do I really have to rename my assemblies to not contain spaces? Is there no way to escape the spaces? I can't find very many instances of people who have this problem, let alone any solutions...

Example XAML:

<UserControl x:Class="SomeClass"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Some.Namespace;assembly=Some Assembly With Spaces In The Name"
    >

And this is the error that the compiler gives you when you try to do this:

Unknown build error, ''clr-namespace:Some.Namespace;assembly=Some Assembly With Spaces In The Name' mapping URI is not valid. Line 4 Position 2.'

Putting ' or &quot; around the assembly name doesn't help.

like image 259
Taudris Avatar asked Mar 16 '11 18:03

Taudris


2 Answers

This solution seems to have fixed the issue for me with spaces in the assembly name.

like image 200
Dewey Vozel Avatar answered Nov 01 '22 18:11

Dewey Vozel


This looks like the bug you're referring to, which is 'fixed'...

I've just had a similar problem with a ValueConverter in a separate assembly, and the way to get it to build was to include a default constructor in my ValueConverter class. Without that, VS won't build it if it's contained in an assembly with spaces in the name.

Unfortunately, it builds but then falls over with a XamlParseException when I actually run it up.

If I do the same referencing an assembly without spaces, everything is fine.

As an aside, you're defining the xmlns:local namespace but referencing a different assembly - if your namespace is indeed local you can just do:

<xmlns:local="clr-namespace:Some.Namespace"/>
like image 1
Town Avatar answered Nov 01 '22 18:11

Town