c# - How to use "InternalsVisibleTo" attribute with Strongly named assembly? -


i using "internalsvisibleto" attribute assembly expose internal methods/classes unit test project.

i need install assembly gac, need give strong name. when try doing that, following error in visual studio.

strong-name signed assemblies must specify public key in internalsvisibleto declarations

a bit of googling brought me article below:

https://msdn.microsoft.com/en-us/library/bb763089.aspx

this article states:

"determine public key strong-named friend assembly."

this article not how determine public key. find public key assembly? also, once have public key, correct way declare attribute?

[assembly: internalsvisibleto("namespace.assembly.example.name, publickey=thepublickey")] 

to use internalsvisibleto signed assembly "friends" assemblies must signed too.

note attribute not used actual validation of assembly @ compile time - specifies run-time checks (and compile-time checks friend's assembly) should validate identity. if just need compile main assembly can specify public key token (i.e. 1 microsoft's assemblies found on assembly references in web.config example).

generally since you'll signing assemblies you'd know public key. i.e. if have snk file sn -t yousnk.snk show public key. or can follow steps in getting public key token of assembly within visual studio configure vs show public token assembly.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -