Microsoft .NET - Tips and Tricks



Monday, February 04, 2008
Unit testing internal units/methods - Friend Assemblies

Why?
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
 

0 Comments:


Post a Comment
+ Blog Home
 

Links

Get the Levi9 RSS Feed
Levi9 Global Sourcing

Previous Posts

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

Archives

February 2007
March 2007
April 2007
January 2008
February 2008

Powered by Blogger
Levi9 Global Sourcing | Jan van Goyenkade 8 | 1075 HP Amsterdam | The Netherlands | +31(0)72 58 210 55 | info@levi9.com
Copyright © Levi 9 | Design by A36