Using Strong Names does some of this and prevents someone else from faking your assembly, but does not stop you from doing it by accident, and then resigns.
We use an independent process to launch our main application. Before starting the main application, start the MD5 application with all the assmeblies and compare them with the list of those that it expects to see, if something has changed, MD5 failed and the main application is not loaded.
If you really need a compile-time check, you could probably write a pre-build step that did the same MD5 comparison and couldn't build the assembly if it changed.
source
share