You can study adding StrongNameIdentityPermissionto your class library, which corresponds to the strong name of the program with which you want to use it.
Alternatively, you can study InternalsVisibleToAttribute, although this may require some design changes in your library code. This should work until either one is signed, or both are signed with a strong name. The argument specified in the attribute must match the public key and the name of the assembly to which you want to access your internal members.
But in reality it will stop only those who are not trying to use your library very much. They won’t be able to add the link, but that doesn’t stop anyone from getting around it through Reflection or disassembling your code. There are always ways to get around almost any security measure that you implement.
source
share