Go to content Go to navigation Go to search

How to Get a Non-signed Assembly to Work with the InternalsVisibleToAttribute

I used the InternalsVisibleToAttribute for the first time today. I put it in my AssemblyInfo.cs file, like so:

[assembly: InternalsVisibleTo("UnitTests.Common.Data")]

When I compiled, I got the following error:

Error 218 Friend assembly reference ‘UnitTests.Common.Data’ is invalid. Strong-name signed assemblies must specify a public key in their InternalsVisibleTo declarations.

The only problem? The assembly wasn’t being signed. I verified this assumption by visiting the Signing tab in the project’s properties.

I then remembered that the pre-Visual Studio 2005 way of signing an assembly was to use some assembly level attributes (e.g. AssemblyDelaySignAttribute, AssemblyKeyFileAttribute, AssemblyKeyNameAttribute, etc.). So, I went into my AssemblyInfo.cs file and removed all signing/key related attributes (specifically, the AssemblyDelaySign, AssemblyKeyFile, and AssemblyKeyName attributes), re-compiled and the error went away.