James
James

Reputation: 3625

Forcing my app to use a specific version of a 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

Upvotes: 3

Views: 1934

Answers (3)

mundeep
mundeep

Reputation: 2747

As Colin mentioned Strong Naming your assemblies will be the key as this includes both versioning & signing the assembly. The following couple of blog posts may help you with strong naming & versioning:

http://www.csharp411.com/net-assembly-faq-part-3-strong-names-and-signing/ (might be also worth reading the next part of this about the Global Assembly Cache)

http://philippetruche.wordpress.com/2008/08/12/net-assembly-versioning-lifecycle/

Upvotes: 1

Colin Desmond
Colin Desmond

Reputation: 4854

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.

Upvotes: 4

Phill Duffy
Phill Duffy

Reputation: 2866

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

Upvotes: 2

Related Questions