Krishna
Krishna

Reputation: 85

DLL comparison to confirm If same source code is used

I am comparing to make sure 2 dlls are generated from same source. As I could not use external tools to compare, I just created IL files using IL disassembler and comparing manually.

Is it safe to assume for the above scenarios that both DLLs are from same source code?

Upvotes: 2

Views: 7080

Answers (3)

Konrad Kokosa
Konrad Kokosa

Reputation: 16878

You can use ILSpy to decompile both DLLs. Use Save Code... option for both libraries, so you can save it as complete Visual Studio project (csproj). Then simple WinMerge (with recursion) on both directories will show you all differences in the source code.

I've recently successfully used this approach to make sure what version of DLL was used on production machines.

Upvotes: 14

NoviceProgrammer
NoviceProgrammer

Reputation: 3365

I think you can try the following -

  1. try ILSpy for an open source assembly browser and decompiler and compare the c# code generated.
  2. run test cases against the classes in the assembly and validate if the results are the same.

Upvotes: 1

CodeCaster
CodeCaster

Reputation: 151586

There's no way to tell this.

Not only are no two compiled DLL's the same because of the MVID and other properties that differ each time you compile: two assemblies containing the same number of methods doesn't tell anything:

  • The implementation of the methods can differ (e.g. v1's Foo() method contains return true, while v2's Foo() contains return false)
  • Different source code can yield the same IL.

It seems like you have an entirely different problem you want to solve, like educating your team and using continuous integration to share assemblies that are compiled on a build server. If you can explain why you want to make sure two DLLs were compiled from the same source, perhaps some better answers can be given.

Upvotes: 3

Related Questions