Roy Osherove

View Original

Denying your public classes from your end customers

Here's a cool way to make sure that no one else but your application can use any of the public classes that are exposed by your business assemblies: you put a permission requirement on the class that requires the strong name of your calling assembly:

[StrongNameIdentityPermission(SecurityActoin.LinkDemand, PublicKey="XXXYY)]

public class MyPublicLogicClass

{

//do something

}

[via Juval Lowy's .Net Master class]