Prevent external assembly injection via PublicKeyToken
问题 I'm using the following code: AppDomain.CurrentDomain.AssemblyLoad += (sender, args) => { var token = args.LoadedAssembly.GetName().GetPublicKeyToken(); if (!IsValidToken(token)) { Process.GetCurrentProcess().Kill(); } }; Where IsValidToken() compares the public key token of the assembly being loaded against a list of authorized public key tokens hardcoded in my application as byte arrays. Is this a good security measure to prevent code injection attacks? Also, is this necessary given the