Microsoft .NET - Tips and Tricks
Monday, February 04, 2008
Unit testing internal units/methods - Friend Assemblies
I was asked about this a few times although there are a number of articles on this subject. The thing is that people usually know about that posibility and how it should be implemented but have difficulties implementing it to the end (especially in case of strongly signed assemblies).
What is the problem?
You set the InternalsVisibleTo attribute on an aseembly level and then you are able to access the internal methods of the assembly from another assembly. But the catch is in the proper way InternalsVisibleTo attribute should be configured.
There were a few examples on web that were not completelly accurate and leaded to confusion. The thing is that number of articles said that PublicKeyToken should be set for strongly named assemblies but actually PublicKey should be set instead.
A very detailed spec with examples on this (and accurate) can be found here: Friend Assemblies (C# Programming Guide)
posted by Popovic Sasa
Links to this post:
+ Blog Home
Get the Levi9 RSS Feed
Levi9 Global Sourcing
+ Signing a 3rd party DLL
+ Custom paging SPGridView control
+ Serving files from server
+ Configuring CruiseControl .Net to work with multip...
+ Sharing cookies between sub-domains
+ February 2007
+ March 2007
+ April 2007
+ January 2008
+ February 2008