Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
787 views
in Technique[技术] by (71.8m points)

.net - Could not load file or assembly 'AssemblyName PublicKeyToken=null' or one of its dependencies

{"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:

  • Signed all the unsigned third-party assemblies my project is referencing.
  • Disassembled those assemblies to see if they internally reference any external unsigned assemblies (they didn't)
  • Deleted the old unsigned assemblies from the project's reference list, and re-added the newly signed ones.
  • Unloaded the project and edited the reference of the assembly that can't be loaded in the .sln XML-styled file by adding the PublicKeyToken that was missing from the assembly reference.

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...