{"Could not load file or assembly 'AssemblyName, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"AssemblyName, PublicKeyToken=null"}
I'm getting the message in question as an InnerException.Message
while trying to debug my application after signing the unsigned third-party assemblies it is using.
The weird thing is that I have already signed the assembly shown in the message, the one that can't be loaded.
What could the problem be here? How can I resolve this?
EDIT
Editing to give more information on what I did:
The assembly that throws the exception, btw the project builds fine it's a runtime exception I'm getting on InitializeComponent()
of that assembly, is an open source component with WPF controls (MahApps.Metro). I've found a similar question but none of the answers there fixed the issue.
How to force WPF to use resource URIs that use assembly strong name? Argh!
This error usually means that the assembly was not found. Try verifying that the file exists in the directory where your application is running.
PublicKeyToken = null tells you that the CLR is looking for the unsigned assembly. Since you signed them, that's not going to work well and this kaboom is expected. You will have to rebuild the program so it uses the updated signed assembly and embeds the non-null PublicKeyToken into the manifest.
In summary if you get the "Could not load file or assembly error", this means that either your projects or their references were built with a reference to a specific version of an assembly which is missing from your bin directory or GAC.
PublicKeyToken = null tells you that the CLR is looking for the unsigned assembly. Since you signed them, that's not going to work well and this kaboom is expected.
You will have to rebuild the program so it uses the updated signed assembly and embeds the non-null PublicKeyToken into the manifest. You may have to remove the existing assembly reference and add it back, it isn't clear from the question whether you built the program using an unsigned copy.
Use the Fuslogvw.exe utility if you still have trouble.
Maybe one of your "unsigned third-party assemblies" has a reference to another one of your "unsigned third-party assemblies" - so the reference is wrong after you signed them all.
Maybe this tool can help you: https://github.com/brutaldev/StrongNameSigner - it can update the assemblies (it probably also can done by using the command line, but I don't know how).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With