Strong-name Unsigned Nothings

A while back I wrote about how to access internal methods in unit tests. When I actually tried to do it, I got the following error message:

error CS1726: Friend assembly reference 'MyDllTests' is invalid. Strong-name signed assemblies must specify a public key in their InternalsVisibleTo declarations.

I looked at the AssemblyInfo.cs, and as I thought, there was no key file or key name specified which means that it’s not signed at all.

However, we had empty attributes in the AssemblyInfo.cs file, the way Microsoft had it in their project templates in Visual Studio 2003:

[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]

Eventually I found that the .NET 2.0 compiler counts this as being strong-name signed, so I commented out those lines and the error went away. Strange.

//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]
//[assembly: AssemblyKeyName("")]


One thought on “Strong-name Unsigned Nothings

  1. Thanks mate,
    I was a bit stumped on this one and I couldn’t understand the error as neither of my assemblies were signed.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s