简体   繁体   中英

C# strong naming and versioning

we need to have a C# application I've written perform an automatic update of one of its main DLLs. The idea is when the .exe launches, it first checks the internet for an update - then downloads that update

once the download is complete we plan on performing a signature check on the DLL before executing

I'm new to the mechanics of .NET assembly signing, especially when it comes to versioned assemblies (going from version 1.0 to version 1.1)

does .NET offer anything that can help me? How do I correctly work within the constraints of strong naming? (can I?)

I'm hoping for guidance and technique in this question, more than API's and the mechanics

I feel, you might need a separate process (say update.exe) to do the job.

Reason: If you have a process running(say MyApp.exe) and if it is using a X.dll (loaded module), then you would not be able to update(replace) X.dll as it would throw an exception

System.IO.IOException : The process cannot access the file 'X.dll' because it is being used by another process.

So, you might have to do this update/replace before loading the X.dll module. If you need to control loading assemblies, then you have to do use Reflections Assembly.Load. If that is OK.

To get the version number of a dll you could use:

Assembly assembly = Assembly.LoadFrom("X.dll");
Version ver = assembly.GetName().Version;

To sign an assembly, you can use external tools like signtool.exe. It is part of the Windows SDK, it takes command line arguments, and you can find out more about it here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM