Decompiling and modifying an Assembly....

  • Thread starter Thread starter Gaz
  • Start date Start date
G

Gaz

....and recompiling it again

Hi all,

I've got an Assembly DLL and associated .NetModules and want to amend
a function in one of the .NetModules

I've used ILDASM to decompile the .NetModules into IL so I can modify
the code but am having trouble trying to compile up the .NetModule and
effectively renew the Assembly.

If I use ILASM to rebuild the .NetModule I get an error
'System.IO.FileLoadException - The check of the modules hash failed'
when trying to use my Assembly DLL so obviously I need to do a full
rebuild of the Assembly DLL.

However, if I try to us AL.exe with any of my NetModule .il files I
get an 'unspecified error' when it tries to import them....

Can anyone tell me the necessary sequence of events required to :
disassemble an Assembly and it's NetModules,
Modify the IL of one of the NetModules,
Rebuild the NetModules and Assembly DLL correctly

I'm new to C# and apologise if this is a daft question, but I've not
seen an answer for disassembling, modifying and rebuilding an Assembly
in the Groups so far and would appreciate any help!

Thanks for your time,

Gareth
 
Gaz said:
I've got an Assembly DLL and associated .NetModules and want to amend
a function in one of the .NetModules

I've used ILDASM to decompile the .NetModules into IL so I can modify
the code but am having trouble trying to compile up the .NetModule and
effectively renew the Assembly.

Do you have the legal right to modify this code? If so, couldn't you
just ask the author for the original source code, modify that, and then
recompile it in a normal way?
 
Gaz,
Legal issues notwithstanding, this is most likely because the assembly you
are attempting to ILASM from il code was a strong-named assembly. You would
have to remove the public key portion and any other similar metadata.
--Peter
 
Back
Top