Reputation: 7856
Another year, another question about Moles. I've got an assembly with an internal sealed class that I'd like to mole in the test project that I use for unit tests.
According to the Moles documentation I should add an
[assembly: InternalsVisibleTo( "MyAssembly.Moles" )]
attribute so I can access the internal class from my test project. However, this unfortunately doesn't work as "MyAssembly" is strongly signed.
Therefore, following the documentation, I added the Public Key to the line above, resulting in
[assembly: InternalsVisibleTo( "MyAssembly.Moles, PublicKey=0123456..." )]
Unfortunately this now gives me the following error when compiling "MyAssembly":
Assembly reference 'MyMoles.Moles, PublicKey=0123456...' is invalid and cannot be resolved
The documentation says that "...the Moles framework always uses the same key to sign the assembly...", but as the compiler says, this does not work. I also checked the generated file "MyAssembly.Moles.dll" with Reflector to verify that I use the correct public key (which I do), so I am stuck as I don't really know what the problem is.
Any ideas?
Upvotes: 1
Views: 1858
Reputation: 1536
Be sure you are entering the PUBLIC KEY, and not the PUBLIC KEY TOKEN.
If that doesn't work, use the secutil, to get the public key. The verbose output will include the correct key value. This is the syntax you need to use:
C:\> secutil -hex -s MyAssemblyName.dll
Upvotes: 3