While trying to add a ressource dictionary into the MergedDictionary of the application, I encounter a parsing error.
System.Windows.Markup.XamlParseException occurred
HResult=-2146233087
Message='Cannot create unknown type '{clr-namespace:Common.UserControls}ButtonVisibilityConverter'.' Line number '4' and line position '6'.
Source=PresentationFramework
LineNumber=4
LinePosition=6
StackTrace:
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, Boolean skipJournaledProperties, Uri baseUri)
at System.Windows.Markup.XamlReader.Load(XamlReader xamlReader, ParserContext parserContext)
at System.Windows.Markup.XamlReader.Load(XmlReader reader, ParserContext parserContext, XamlParseMode parseMode)
at System.Windows.Markup.XamlReader.Load(Stream stream, ParserContext parserContext)
at MS.Internal.AppModel.AppModelKnownContentFactory.XamlConverter(Stream stream, Uri baseUri, Boolean canUseTopLevelBrowser, Boolean sandboxExternalContent, Boolean allowAsync, Boolean isJournalNavigation, XamlReader& asyncObjectConverter)
at MS.Internal.AppModel.MimeObjectFactory.GetObjectAndCloseStream(Stream s, ContentType contentType, Uri baseUri, Boolean canUseTopLevelBrowser, Boolean sandboxExternalContent, Boolean allowAsync, Boolean isJournalNavigation, XamlReader& asyncObjectConverter)
at System.Windows.ResourceDictionary.set_Source(Uri value)
at Common.Infrastructure.Bootstrapper.InitializeGlobalRessources() in e:\xxxxx\Common\Infrastructure\Bootstrapper.cs:line 113
InnerException: System.Xaml.XamlObjectWriterException
HResult=-2146233088
Message='Cannot create unknown type '{clr-namespace:Common.UserControls}ButtonVisibilityConverter'.' Line number '4' and line position '6'.
Source=System.Xaml
LineNumber=4
LinePosition=6
StackTrace:
at System.Xaml.XamlObjectWriter.WriteStartObject(XamlType xamlType)
at System.Xaml.XamlWriter.WriteNode(XamlReader reader)
at System.Windows.Markup.WpfXamlLoader.TransformNodes(XamlReader xamlReader, XamlObjectWriter xamlWriter, Boolean onlyLoadOneNode, Boolean skipJournaledProperties, Boolean shouldPassLineNumberInfo, IXamlLineInfo xamlLineInfo, IXamlLineInfoConsumer xamlLineInfoConsumer, XamlContextStack`1 stack, IStyleConnector styleConnector)
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
InnerException:
Which seems to point to an error with the declaration of my converter, but I can't figure out why.
Is here my loaded resource
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Common.UserControls">
<local:ButtonVisibilityConverter x:Key="PageButtonVisibilityConverter"/>
....
</ResourceDictionary>
The converter declaration:
namespace Common.UserControls
{
public class ButtonVisibilityConverter : IMultiValueConverter{
...
}
}
The code that is loading the dictionary: ResourceDictionary dictionary = new ResourceDictionary {Source = new Uri("/Common;Component/UserControls/Generic.xaml", UriKind.RelativeOrAbsolute)};
The converter and the resource are in the same folder. The code loading the resource is in the same project.
I've no idea what is going wrong, because yesterday everything was working, so I'm not sure if I introduced a change by error or if there is something else to check?
I already cleared my whole output directory.
Also, the namespace declaration for the converter has been created directly by Resharper and it is rarely wrong.
Thank you for the help