Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forcing my app to use a specific version of a dll

Tags:

c#

.net

dll

I have application which needs to use a dll (also written by me) which has be independently verified by a government agency. We plan to modify the dll very rarely due to the re-verification which would be required. I want to prevent inadvertent modifications to this dll being picked up by my application. Is there a way to create a hash code for the dll and set up my application to only use this specific version.

This way if someone modified some of the code for the dll, when we build and run the application the app would fail to load the dll (because it had changed).

Any ideas/suggestions?

Cheers,

James

like image 472
James Avatar asked Sep 14 '25 00:09

James


2 Answers

Using Strong Names does part of this and prevent anyone else tampering with your assembly, but doesn't stop you doing it by accident and then resigning.

We use an independent process to start our main application. Before launching the main app, the start up app MD5's all the assmeblies and compares them against a list of those it expects to see, if something has changed, the MD5 fails and the main app is not loaded.

If you really wanted compile time checking, you could probably write a pre-build step that did the same MD5 comparison and failed the build if it had changed.

like image 191
Colin Desmond Avatar answered Sep 16 '25 16:09

Colin Desmond


I know that if you click on a dll Reference in your project you can select 'Specific Version' in its properties and set it to True, will this not do what you are after?

Phill

like image 31
Phill Duffy Avatar answered Sep 16 '25 16:09

Phill Duffy