.Net Friend Assemblies

Have you ever want to create a “friend” assembly while programming with the .Net framework?  They can be very useful for segmenting your codebase amongst different projects.

Friend Assemblies allow an assembly to see the internal methods and properties of a different assembly by specifying an attribute on the primary assembly that specifies the assembly name of the friend.

The simplest way to do this is to add something like the following to your AssemblyInfo.cs file in your primary project:

[assembly: InternalsVisibleTo(“my.friend.assembly”)]

This would allow my.friend.assembly to have access to all of the primary project’s internals.

If you need to worry about security of the assemblies (I suppose we all should), then you should also consider using strong names in conjunction with the compiler attribute.

More information on .Net Friend Assemblies can be found here:


Hope this helps!

This entry was posted in C#. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *