mercredi 24 juin 2015

WPF - ResourceDictionaries with namespaces in signed assembly

I've created a ResourceDictionary in my WPF project that imports namespaces from within the same project. I have digitally signed my project and given it a strong name. When I run my project in Visual Studio, it behaves as expected. When I run the exe from Windows Explorer, the application throws an error saying that it could not load the assembly for my WPF project.

When I look closely at the error message, I see that it is listing the correct name of the assembly, but the PublicTokenKey=null even though the assembly is signed. This happens on a Application.FindResource call that I use in my App.xaml.cs to load the resource. It appears the the reflection that is happening in the FindResource call is trying to load an unsigned version of the assembly but finding the signed version and thus the manifests don't match.

I have been able to come up with a work around where I removed the namespaces from my ResourceDictionary, and instead when I instantiate the resource object in my App.xaml.cs I add the properties that I was previously setting in the ResourceDictionary xaml. This works correctly, but is not ideal as these things would be better declared in the xaml.

Any ideas what could be going on here? Anyone else experienced this?





Aucun commentaire:

Enregistrer un commentaire