It's my football and I'm going home

We've all created API libraries, and libraries by their nature encourage resuse.
However what happens if you want to be selective in who else uses your assembly?
One simplistic approach would be to ensure that the calling assembly has the same public key


private void CheckCallerAllowed()
{
var myPubKeyToken = Assembly.GetExecutingAssembly().GetName().GetPublicKeyToken();
var entryPubKeyToken = Assembly.GetEntryAssembly().GetName().GetPublicKeyToken();

if (myPubKeyToken.Length != entryPubKeyToken.Length)
    throw new ApplicationException("Assembly not licensed");

for (int idx = 0; idx < myPubKeyToken.Count(); ++idx)
   
if (myPubKeyToken[idx] != entryPubKeyToken[idx])
       
throw new ApplicationException("Assembly not licensed");
}

 

Place a call to the function above in your public interface.

Recent Tweets

Note: For Customization and Configuration, CheckOut Recent Tweets Documentation

Calendar

<<  July 2017  >>
MoTuWeThFrSaSu
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

View posts in large calendar

Month List