access another assembly c# code example

Example: C# how to expose an internal class to another project in the solution

/*
1) Open a command prompt
2) Generate a strong-name key for the project and store it in the file FriendAssemblies.snk:

   sn -k FriendAssemblies.snk

3) Extract the public key from FriendAssemblies.snk and put it into FriendAssemblies.publickey:

   sn -p FriendAssemblies.snk FriendAssemblies.publickey

4) Display the public key stored in the file FriendAssemblies.publickey, and copy it to your clipboard:

   sn -tp FriendAssemblies.publickey
   
5) Update your C# class file with the displayed public key using the "InternalsVisibleTo" attribute:
*/

using System.Runtime.CompilerServices;  
[assembly: InternalsVisibleTo("friend_signed_B, PublicKey=" +
"0024000004800000940000000602000000240000525341310004000001000100e3ae" +
"dce99b7e10823920206f8e46cd5558b4ec7345bd1a5b201ffe71660625dcb8f9a086" +
"87d881c8f65a0dcf042f81475d2e88f3e3e273c8311ee40f952db306c02fbfc5d8bc" +
"6ee1e924e6ec8fe8c01932e0648a0d3e5695134af3bb7fab370d3012d083fa6b8317" +
"9dd3d031053f72fc1f7da8459140b0af5afc4d2804deccb6")]  
internal class Class1  
{  
    ...  
}