Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 962
AndyD273 Avatar asked Jun 01 '11 18:06

AndyD273


1 Answers

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.
like image 57
Kent Boogaart Avatar answered Oct 28 '22 15:10

Kent Boogaart