Why would I see "Unable to emit assembly: Referenced assembly ... does not have a strong name" when trying to add a reference?

11,431

Solution 1

You will need to add a strong name to the other assembly, or make your project not include a strong name.

Since you're already building it, you can just add a strong name in the project properties, and rebuild. Once you do that, it should work (without changing the code at all).

Solution 2

This is a security constraint. Put simply, if you strongly-name your assembly, you are providing a guarantee to consumers of your assembly that only your assembly and its dependencies will be loaded at runtime. Malicious parties will not be able to replace your assembly with an impostor (unless they have your key, of course).

If your strongly-named assembly references weakly-named assemblies, that guarantee cannot be met because its dependencies could be substituted for impostors. That is why you're getting the compile error.

Your options are:

  1. Remove the strong name from your assembly.
  2. Strongly-name the third party code at compile-time. This is easy in your case because you're building from source.
  3. Strongly-name the third party binaries using ILMerge. This is an attractive option if you aren't building from source and the third party neglected to sign their assembly.

Solution 3

In plain words, this means that you have a project named AssemblyA which references AssemblyB. AssemblyA is signed, AssemblyB is not.

You will have to decide either to also sign AssemblyB, or not sign AssemblyA.

Share:
11,431
AndyD273
Author by

AndyD273

Here for the programming and world building.

Updated on July 05, 2022

Comments

  • AndyD273
    AndyD273 almost 2 years

    I'm wanting to include a system tray icon in my WPF project, and found this resource:

    http://www.hardcodet.net/projects/wpf-notifyicon

    which looks like it will work beautifully, but it's written for C# and I'm using VB.net for this project. I downloaded his project and built the notifyicon as a DLL, then added as a reference to my project.

    It throws up an error:

    Unable to emit assembly: Referenced assembly 'Hardcodet.Wpf.TaskbarNotification' does not have a strong name

    So I'm trying to figure out the best way to proceed. Do I need to strong name it, or is there a better way to do this?

  • Admin
    Admin over 11 years
    he means you have to sign it.