Search code examples
c#.net.net-assemblyinternalsvisibleto

Why has an InternalsVisibleTo referenced assembly also be signed?


I have a strongly named c# assembly: Strong.Named.Assembly.dll. It has the attribute InternalsVisibleTo with its public key, for another assembly: [assembly: InternalsVisibleTo("Another.Assembly, PublicKey=xxx")]. The Anoter.Assembly has not been signed. And so I was not able to reference classes in the Strong.Named.Assembly until I singed the Another.Assembly, too.

Why isn't it possible to show to internals of a strongly named assembly to a not signed one?


Solution

  • Take a look at the MSDN InternalsVisibleToAttribute Class. The documentation states clear that "Both the current assembly and the friend assembly must be unsigned, or both assemblies must be signed with a strong name."

    I think the reason for that is obvious. It guarantees that the assembly you grant internal access to cannot attack your implementation if it changes in future.