puzzlecracker said:
Class cannot be internal, hence I would need to make constructors and
member methods to prevent internal classes from leaking to outside?
thanks
Using StrongNameIdentityPermission it doesn't matter what visibility the
classes have. You can even put it on the entire assembly if you want nothing
at all available to unknown assemblies. However, you are not guaranteed that
identity permissions won't get bypassed by priviliged code, in which case you
may have no other option than to compare the current assembly's public key to
the calling assembly's public key in every constructor, using code similar to
the below
void CheckAssemblies()
{
Assembly currentAssembly = Assembly.GetAssembly(this.GetType());
Assembly callingAssembly = Assembly.GetEntryAssembly();
byte[] currentKeyData = currentAssembly.GetName().GetPublicKey();
byte[] callingKeyData = callingAssembly.GetName().GetPublicKey();
if (currentKeyData.Length != callingKeyData.Length)
throw new SecurityException("Illegal calling assembly");
for (int i = 0; i < currentKeyData.Length; i++)
{
if (currentKeyData
!= callingKeyData)
throw new SecurityException("Illegal calling assembly");
}
}