c# - How do I use Strong Assembly names and key files to verify that the DLL I'm loading is what I expect? -


I am getting a project where I need to programmatically load the DLL and run some code in them. DLL and their dependencies are stored in a database, and I write them on disk, but I want to know whether any DLL is already there before it is already written or not. Currently, the database contains the strong Assembly name and binary data and version number of the file. I am thinking that in order to check against the keys of the existing files in the DLL directory, I need to collect the public key for assembly. I

I know that I have the AssemblyName.GetPublicKey () Can I get the public key of assemblies using Should I also store the public key of the database file? If your code does not have a public key, how can one assembly be verified (may be)? All the code examples I have found is to show the public key in fact or to check if a strong name exists.

Right now, I am working on a library management class which has only one dictionary in its core. It checks the dll directory on startup and adds the public key of each file in the dictionary. Then, when I have to see if the assembly is already on the disk, then I can only check the dictionary (but its requirement Is that I am accumulating the public key in the database). It also uses FileSystemWatcher to monitor any changes in libraries. If I need to write an updated assembly, then I simply overwrite one on the disk and update the class dictionary.

I think you can reuse the SN data, but I do not want to. First of all, it is not enough to get the public key, which is not going from version to version. Instead, you will need to remove the hash that is encrypted with the private key. I do not know how to do this, so one of the reasons is that I will try something else.

Instead, I will make sure that the version number of each build was unique and used only by it. If you really want, you can use SHA1 class to run your heash, but it's going crazy.

Edit

Just to be clear, the public key is used to decrypt the hash stored, which is then compared to the newly generated hash It is compared that any public key will work, which is why the loading program has to use a strong name, which specifies the approved public key.

In addition, you should store not only the public key but also the strong name. It contains the version and the public key.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -