2

Here is the situation. I have DLLs A and B. A.dll reference and uses code in B.dll. B.dLL isn't doing what it is supposed to, so I'm trying to add some debug statements to it.

I Decompile B.dll using ilSpy and add the code I want, compile a new B.dll, delete the old one and drop in my new one.

Now A.DLL fails with This error.

System.IO.FileLoadException: Could not load file or assembly 'B, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b089z623fagfd396' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'B, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b089z623fagfd393'

Since I don't have the source code or private key, I don't think it is possible for me to get my DLL's public key to match the old one. Since that key doesn't match, the reference fails. Is this by design? Is the structure built specifically to prevent me from doing what i'm trying to do. Essentially, I guess I am hacking an application which I don't have source for.

Is there anyway i could do this?

I guess I could just Decompile and rebuild A.dll as well, but there are actually around 200 DLLs all referencing each other.

TizzyFoe
  • 1,489
  • 1
  • 15
  • 28

1 Answers1

1

Is the structure built specifically to prevent me from doing what i'm trying to do.

Yes, one of the reasons to strong name an assembly (give it a public key token) is to prevent the exact process you are trying to do.

As for alternatives to having to re-compile 100's of DLLs it is possible to disable verification for that key using the sn tool so in theory all you need to do is

sn –Vr *,b089z623fagfd393

And all assembiles that are looking for any DLL signed with the key b089z623fagfd393 will no longer error if it tries to load a DLL with no key.

When you are done testing you can either do

sn –Vu *,b089z623fagfd393

to re-enable it for that single key or

sn -Vx

to re-enable it for all previously set exemptions.

Scott Chamberlain
  • 124,994
  • 33
  • 282
  • 431