It’s been a couple of years since I first learned about the InternalsVisibleTo attribute. It took until this afternoon to discover a problem with it. This issue only occurs when you attempt to unit test internal classes of signed assemblies with an unsigned test assembly. If you attempt to compile a Visual Studio solution in this case, the compiler will return the following complaint (among others):
Strong-name signed assemblies must specify a public key intheir InternalsVisibleTo declarations.
Thankfully, this blog post gives a great walk-through of how to get this working. The instructions in brief:
- Sign your test assembly.
- Extract the public key.
- Update your InternalsVisibleTo argument to include the public key.