4

I am creating a Resource Dictionary, where I reference all my converters, so there is no need to reference each individual converter. My converters are in the different assembly, to import them I do the following:

  1. Add reference to external assembly
  2. Create a Resource Dictionary
  3. Add xml namespace referencing Converters assembly
  4. Reference converters

So my Dictionary looks like:

    <ResourceDictionary xmlns:Converters="clr-namespace:Client.Utilities.Converters;assembly=Client.Utilities">

    <Converters:BoolToBrushConverter x:Key="boolToBrush"/>

</ResourceDictionary>

However I get the following exception when trying to build:

Error   18  The tag 'BoolToBrushConverter' does not exist in XML namespace 'clr-namespace:Client.Utilities.Converters;assembly=.Client.Utilities'. Line 12 Position 6.  C:\Resources.Tests\Resources\ResourceDictionaries\Converters\ConvertersResources.xaml   12  6   Client.eZenith.Resources.Tests

Any ideas why that is happening?

Note: From intellisense it seems that namespace for Converters assembly is correct, as all converters show up in the suggestion list after typing <Converter:

Edit: VS and blend designer both are able to find that converter, when rendering control preview.

Edit: I have figured out, that it is nothing to do with dictionaries being merged. The same issue appears, when adding a converter to Window's Resources.

Vitalij
  • 4,587
  • 9
  • 42
  • 65

2 Answers2

1

I have found the problem eventually, it is merged resourcedictionary bug introduce in .NET 4.

I have fixed it by adding an empty style into the merged resource dictionary (previously I had a RD where I was merging other RD and nothing else).

here is a blog post which I found recently which describes the same problem.

Vitalij
  • 4,587
  • 9
  • 42
  • 65
0

Try using

<ResourceDictionary xmlns:Converters="clr-namespace:Client.Utilities.Converters;assembly=Client.Utilities">

instead.
Change: clr-namespace instead of namespace.

Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443