I've got a project going where I need to programmatically load DLLs and run some code in them. The DLLs and their dependencies are stored in a database, and I write them to disk, but I want to check if a DLL is already there before writing it again. Currently, the database contains the strong assembly name and binary data of the file and a version number. I'm thinking I also need to store the public key for the assembly to check against the key of the existing files in the DLL directory.
I know I can get the public key of the assemblies using AssemblyName.GetPublicKey(). Should I just store the public key of the file in the database also? How is an assembly verified if you don't have the public key in your code (can it be)? All the code examples I have found really just show getting the public key or checking that a strong name exists.
Right now, I'm working on a library management class that is just a Dictionary at it core. It checks the dll directory on start up and adds the public key of each file to the dictionary. Then, when I need to check if an assembly is already on disk, I can just check the dictionary (but this requires me storing the public key in the database). It also uses FileSystemWatcher to monitor any changes to the libraries. If I need to write an updated assembly, I just overwrite the one on disk and the class updates the dictionary.