I have a C# project which when compiled on different machines generate dlls which are not binary equal. So my question is why the generated dlls are different? and is there some way to get exactly same dll generated on different machines?
EDIT
Here is what i am trying to do. There are multiple client machines which get some code snippet from a server and compile it. After the dll is compiled, it get used over and over again on the client. If I could have the same DLLs generated on all machines then I can easily check that the DLL is not tampered with on the client side using cryptographic hash.
For some reasons the code has to be compiled at the client machine. Therefore digital signing is not an option.
You cannot expect binaries to be same for any file recreated – let alone assemblies. All document metadata including data created, date modified will be different.If you need to compare, you need to sign the assembly (strong naming) and compare the public key token plus assembly version.
UPDATE
What you are doing is asking for trouble although I can understand sometimes this has to be done. If I were you, I would compile the binary on server and get the clients to download the binary and not the code. At the end of the day, clients might not have the C# compiler on their machine.
To answer your question, if you insist on compiling on client, everytime you compile, create a local hash and store in registry, some file, etc and then compare that hash.
UPDATE 2
C# compiler never guarantees that it is going to create the same binary. Many things are created at the compiled time for example naming anonymous functions, backing value for automatic properties, anonymous methods, internal GUIDs… all of these will be created at compile time and while compiler uses a naming convention which names end up usually the same, it is not guaranteed.