Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are these differences in two DLL file generated from the same source code

All my code is under source control, so I'm 100% sure that the source code hasn't changed. But if I build a C# DLL two times their content is slightly different. I can reproduce the problem 100% of the time by just building, and then building again.

This doesn't seem to impact the program at all, but tools like MSIMSP, used for creating patches from two MSI files are thrown off by these minute changes. Making patches (for my product) 40x bigger than they should be.

I've decompiled both DLLs and their assembly information, classes, etc... are exactly the same. The files are also exactly the same size, but of course have a different creation time. So I really cannot fathom what has changed.

So I dug a little deeper.

I've used WinDiff to find the changes and then cross referenced these in a hex editor. WinDiff shows a change in the second 'line' and in a line at about 80% of the file.

In the hex editor I see that the first byte that is changed is byte 0x088 (byte 136). This seems to be the only byte changed on this 'line'. I trouble finding the second change as WinDiff doesn't tell me the exact byte offset of the change.

Here is an image of the changes, the right file is the contents of the newer file. Hex view

Does anybody familiar with the make-up of (C#) DLL files know what the changed byte might mean? Or better yet how to make sure that DLL files stay exactly the same when you rebuild them?

like image 985
Roy T. Avatar asked Dec 02 '16 10:12

Roy T.


People also ask

How do I use two versions of the same DLL in the same project?

config. Under <runtime> , add a <codeBase> tag for each version of the DLL. This will resolve the runtime assembly loading conflict. That's it, now we can use both versions as we please.

Can two applications use the same DLL?

DLL's are shared resources on the same machine and can be used by multiple process on the same machine.

How many types of DLL files are there?

There are two types of DLLs: simple and complex. A simple DLL contains only DLL code in which special code sequences are generated by the compiler for referencing functions and external variables, and using function pointers.


1 Answers

This might have something to do with differences between Build and a ReBuild

Difference between Build Solution, Rebuild Solution, and Clean Solution in Visual Studio?

if it doesn't think it needs to rebuild a project, it won't. It may also use partially-built bits of the project if they haven't changed

Performing a build uses metadata behind the scenes and thus your dll's can be different

Why is a different dll produced after a clean build, with no code changes?

SOLUTION:

You will need to perform a deterministic build as described here

like image 199
Fuzzybear Avatar answered Oct 17 '22 17:10

Fuzzybear