[c#] How to fix "Referenced assembly does not have a strong name" error?

I've added a weakly named assembly to my Visual Studio 2005 project (which is strongly named). I'm now getting the error:

"Referenced assembly 'xxxxxxxx' does not have a strong name"

Do I need to sign this third-party assembly?

The answer is


First make sure all nuget packages are at the same version across all projects in your solution. e.g. you dont want one project to reference NLog 4.0.0.0 and another project to reference NLog 4.1.0.0. Then try reinstalling nuget packages with

Update-Package -reinstall

I had 3 3rd party assemblies that were referenced by my assembly A and only 2 were included in References by my assembly B which also referenced A.

The missing reference to the 3rd party assembly was added by the update package command, and the error went away.


For me, the problem was a NuGet package without a strong name. The solution was to install StrongNamer from NuGet, which automatically adds a strong name to all referenced assemblies. Just simply having it referenced in the project fixed my issue.


Expand the project file that is using the project that does not "have a strong name key" and look for the .snk file (.StrongNameKey).

Browse through to this file in Windows Explorer (just so that you know where it is).

Back in Visual Studio in the project that does not "have a strong name key", do

  • Right click on the project file
  • Select Properties
  • Select "Signing tab" (on the left)
  • Click the check box "Sign the assembly"
  • Then <Browse> to the .snk file you found earlier

That should do the trick. This solved a problem for me for one project using a form inside another project in the same solution.

I hope it helps.


I had this issue for an app that was strongly named then had to change it in order to reference a non-strongly named assembly, so I unchecked 'Sign the assembly' in the project properties Signing section but it still complained. I figured it had to be an artifact somewhere causing the problem since I did everything else correctly and it was just that. I found and removed the line: [assembly: AssemblyKeyFile("yourkeyfilename.snk")] from its assemblyInfo.cs file. Then no build complaints after that.


Old question, but I'm surprised no one has mentioned ilmerge yet. ilmerge is from Microsoft, but not shipped with VS or the SDKs. You can download it from here though. There is also a github repository. You can also install from nuget:

PM>Install-Package ilmerge

To use:

ilmerge assembly.dll /keyfile:key.snk /out:assembly.dll /targetplatform:v4,C:\Windows\Microsoft.NET\Framework\v4.0.30319 /ndebug

If needed, You can generate your own keyfile using sn (from VS):

sn -k key.snk

Situation: You had project A,B,C,D in solution X,Y

Project A, B, C in X Project A, C, D in Y

I need use project C in project A, but later i dont use. In bin Debug project A had C.dll.

If I compile solution X, all good ( in this solution i delete reference A -> C. ), but in solution Y I get this problem.

Solution is delete C.dll in project A bin Debug


Removing the "Sign the assembly" check mark under the "Signing" tab works as @Michal Stefanow said.

Add here is the simplest way to sign your own files and/or other people's files. You just need to add this line under the "Post-build event command line":

"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\signtool.exe" sign /f "$(ProjectDir)\YourPfxFileNameHere.pfx" /p YourPfxFilePasswordHere /d "Your software title here" /du http://www.yourWebsiteHere.com /t http://timestamp.verisign.com/scripts/timstamp.dll /v "$(BaseOutputPath)$(TargetFileName)"

You can sign other people's files or your own files and as many as you want.

enter image description here


Situation: You had project A,B,C,D in solution X,Y

Project A, B, C in X Project A, C, D in Y

I need use project C in project A, but later i dont use. In bin Debug project A had C.dll.

If I compile solution X, all good ( in this solution i delete reference A -> C. ), but in solution Y I get this problem.

Solution is delete C.dll in project A bin Debug


Removing the "Sign the assembly" check mark under the "Signing" tab works as @Michal Stefanow said.

Add here is the simplest way to sign your own files and/or other people's files. You just need to add this line under the "Post-build event command line":

"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\signtool.exe" sign /f "$(ProjectDir)\YourPfxFileNameHere.pfx" /p YourPfxFilePasswordHere /d "Your software title here" /du http://www.yourWebsiteHere.com /t http://timestamp.verisign.com/scripts/timstamp.dll /v "$(BaseOutputPath)$(TargetFileName)"

You can sign other people's files or your own files and as many as you want.

enter image description here


You can use unsigned assemblies if your assembly is also unsigned.


I was running into this with a ServiceStack dll I had installed with nuget. Turns out there was another set of dlls available that were labeled signed. Not going to be the answer for everyone, but you may just need to check for an existing signed version of your assembly. ServiceStack.Signed


Signing the third party assembly worked for me:

http://www.codeproject.com/Tips/341645/Referenced-assembly-does-not-have-a-strong-name

EDIT: I've learned that it's helpful to post steps in case the linked article is no longer valid. All credit goes to Hiren Khirsaria:

  1. Run visual studio command prompt and go to directory where your DLL located.

    For Example my DLL is located in D:/hiren/Test.dll

  2. Now create the IL file using the command below.

    D:/hiren> ildasm /all /out=Test.il Test.dll (this command generates the code library)

  3. Generate new key to sign your project.

    D:/hiren> sn -k mykey.snk

  4. Now sign your library using ilasm command.

    D:/hiren> ilasm /dll /key=mykey.snk Test.il


How to sign an unsigned third-party assembly

  1. Open up Developer Command Prompt for Visual Studio. This tool is available in your Window programs and can be found using the default Windows search.
  2. Ensure your prompt has access to the following tools by executing them once: sn ildasm and ilasm
  3. Navigate to the folder where your Cool.Library.dll is located
  4. sn –k Cool.Library.snk to create a new key pair
  5. ildasm Cool.Library.dll /out:Cool.Library.il to disassemble the library
  6. move Cool.Library.dll Cool.Library.unsigned.dll to keep the original library as a back-up
  7. ilasm Cool.Library.il /dll /resource=Cool.Library.res /key=Cool.Library.snk to reassemble the library with a strong name
  8. powershell -command "& {[System.Reflection.AssemblyName]::GetAssemblyName($args).FullName} Cool.Library.dll" to get the assembly fully qualified name. You will need this bit if you have to reference the DLL in external configuration files like web.config or app.config.

Old question, but I'm surprised no one has mentioned ilmerge yet. ilmerge is from Microsoft, but not shipped with VS or the SDKs. You can download it from here though. There is also a github repository. You can also install from nuget:

PM>Install-Package ilmerge

To use:

ilmerge assembly.dll /keyfile:key.snk /out:assembly.dll /targetplatform:v4,C:\Windows\Microsoft.NET\Framework\v4.0.30319 /ndebug

If needed, You can generate your own keyfile using sn (from VS):

sn -k key.snk

You can use unsigned assemblies if your assembly is also unsigned.


I was searching for solution to the very same problem and un-ticking "Sign the assembly" option works for me:

enter image description here

(as you may notice screenshot comes from VS2010 but hopefully it will help someone)


Signing the third party assembly worked for me:

http://www.codeproject.com/Tips/341645/Referenced-assembly-does-not-have-a-strong-name

EDIT: I've learned that it's helpful to post steps in case the linked article is no longer valid. All credit goes to Hiren Khirsaria:

  1. Run visual studio command prompt and go to directory where your DLL located.

    For Example my DLL is located in D:/hiren/Test.dll

  2. Now create the IL file using the command below.

    D:/hiren> ildasm /all /out=Test.il Test.dll (this command generates the code library)

  3. Generate new key to sign your project.

    D:/hiren> sn -k mykey.snk

  4. Now sign your library using ilasm command.

    D:/hiren> ilasm /dll /key=mykey.snk Test.il


I have written a tool to automatically strong-name sign assemblies including ones you do not have the source code for or projects that have been abandoned. It uses many of the techniques described in the answers in a simple way without any of the flaws or drawbacks of existing tools or dated instructions.

http://brutaldev.com/post/2013/10/18/NET-Assembly-Strong-Name-Signer

Hope this helps out anyone that need to sign a third party assembly without having to jump through hoops to get there.


I was searching for solution to the very same problem and un-ticking "Sign the assembly" option works for me:

enter image description here

(as you may notice screenshot comes from VS2010 but hopefully it will help someone)


I have written a tool to automatically strong-name sign assemblies including ones you do not have the source code for or projects that have been abandoned. It uses many of the techniques described in the answers in a simple way without any of the flaws or drawbacks of existing tools or dated instructions.

http://brutaldev.com/post/2013/10/18/NET-Assembly-Strong-Name-Signer

Hope this helps out anyone that need to sign a third party assembly without having to jump through hoops to get there.


Expand the project file that is using the project that does not "have a strong name key" and look for the .snk file (.StrongNameKey).

Browse through to this file in Windows Explorer (just so that you know where it is).

Back in Visual Studio in the project that does not "have a strong name key", do

  • Right click on the project file
  • Select Properties
  • Select "Signing tab" (on the left)
  • Click the check box "Sign the assembly"
  • Then <Browse> to the .snk file you found earlier

That should do the trick. This solved a problem for me for one project using a form inside another project in the same solution.

I hope it helps.


For me my issue was that I had two of the same NuGet Packages installed with different Versions.


There is a NuGet package named StrongNamer by Daniel Plaisted that seems to do the trick.

Is the simplest solution that I've found so far.

There are also a number of other NuGet packages to fix the strong naming problem such as Brutal.Dev.StrongNameSigner by Werner van Deventer, but I have not tested that one or any of the others.


First make sure all nuget packages are at the same version across all projects in your solution. e.g. you dont want one project to reference NLog 4.0.0.0 and another project to reference NLog 4.1.0.0. Then try reinstalling nuget packages with

Update-Package -reinstall

I had 3 3rd party assemblies that were referenced by my assembly A and only 2 were included in References by my assembly B which also referenced A.

The missing reference to the 3rd party assembly was added by the update package command, and the error went away.


There is a NuGet package named StrongNamer by Daniel Plaisted that seems to do the trick.

Is the simplest solution that I've found so far.

There are also a number of other NuGet packages to fix the strong naming problem such as Brutal.Dev.StrongNameSigner by Werner van Deventer, but I have not tested that one or any of the others.


For me my issue was that I had two of the same NuGet Packages installed with different Versions.


For me, the problem was a NuGet package without a strong name. The solution was to install StrongNamer from NuGet, which automatically adds a strong name to all referenced assemblies. Just simply having it referenced in the project fixed my issue.


I was running into this with a ServiceStack dll I had installed with nuget. Turns out there was another set of dlls available that were labeled signed. Not going to be the answer for everyone, but you may just need to check for an existing signed version of your assembly. ServiceStack.Signed


I had this issue for an app that was strongly named then had to change it in order to reference a non-strongly named assembly, so I unchecked 'Sign the assembly' in the project properties Signing section but it still complained. I figured it had to be an artifact somewhere causing the problem since I did everything else correctly and it was just that. I found and removed the line: [assembly: AssemblyKeyFile("yourkeyfilename.snk")] from its assemblyInfo.cs file. Then no build complaints after that.


How to sign an unsigned third-party assembly

  1. Open up Developer Command Prompt for Visual Studio. This tool is available in your Window programs and can be found using the default Windows search.
  2. Ensure your prompt has access to the following tools by executing them once: sn ildasm and ilasm
  3. Navigate to the folder where your Cool.Library.dll is located
  4. sn –k Cool.Library.snk to create a new key pair
  5. ildasm Cool.Library.dll /out:Cool.Library.il to disassemble the library
  6. move Cool.Library.dll Cool.Library.unsigned.dll to keep the original library as a back-up
  7. ilasm Cool.Library.il /dll /resource=Cool.Library.res /key=Cool.Library.snk to reassemble the library with a strong name
  8. powershell -command "& {[System.Reflection.AssemblyName]::GetAssemblyName($args).FullName} Cool.Library.dll" to get the assembly fully qualified name. You will need this bit if you have to reference the DLL in external configuration files like web.config or app.config.

Examples related to c#

How can I convert this one line of ActionScript to C#? Microsoft Advertising SDK doesn't deliverer ads How to use a global array in C#? How to correctly write async method? C# - insert values from file into two arrays Uploading into folder in FTP? Are these methods thread safe? dotnet ef not found in .NET Core 3 HTTP Error 500.30 - ANCM In-Process Start Failure Best way to "push" into C# array

Examples related to visual-studio

VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio? How to download Visual Studio Community Edition 2015 (not 2017) Cannot open include file: 'stdio.h' - Visual Studio Community 2017 - C++ Error How to fix the error "Windows SDK version 8.1" was not found? Visual Studio Code pylint: Unable to import 'protorpc' Open the terminal in visual studio? Is Visual Studio Community a 30 day trial? How can I run NUnit tests in Visual Studio 2017? Visual Studio 2017: Display method references

Examples related to visual-studio-2005

How to generate List<String> from SQL query? Unable to copy file - access to the path is denied How do I print to the debug output window in a Win32 app? How to debug a referenced dll (having pdb) What is the difference between Release and Debug modes in Visual Studio? The name 'controlname' does not exist in the current context How do I programmatically get the GUID of an application in .NET 2.0 Cannot find Dumpbin.exe How to fix "Referenced assembly does not have a strong name" error? ERROR : [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Examples related to assemblies

Could not load file or assembly for Oracle.DataAccess in .NET How can I get the assembly file version How to extract an assembly from the GAC? How to Load an Assembly to AppDomain with all references recursively? Can I load a .NET assembly at runtime and instantiate a type knowing only the name? How do I list all loaded assemblies? "Are you missing an assembly reference?" compile error - Visual Studio How can I reference a dll in the GAC from Visual Studio? How to fix "Referenced assembly does not have a strong name" error? How can I determine if a .NET assembly was built for x86 or x64?

Examples related to strongname

“Unable to find manifest signing certificate in the certificate store” - even when add new key How to fix "Referenced assembly does not have a strong name" error?