I am trying to use the InternalsVisibleTo assembly attribute to make my internal classes in a .NET class library visible to my unit test project. For some reason, I keep getting an error message that says:
‘MyClassName’ is inaccessible due to its protection level
Both assemblies are signed and I have the correct key listed in the attribute declaration. Any ideas?
Are you absolutely sure you have the correct public key specified in the attribute? Note that you need to specify the full public key, not just the public key token. It looks something like:
It’s 320 or so hex digits. Not sure why you need to specify the full public key – possibly with just the public key token that is used in other assembly references it would be easier for someone to spoof the friend assembly’s identity.