-2

I am trying to decompile one of our old source codes which had been developed in .Net 1.1. I have tried couple of different decompiler tools but none of them were able to give me a good result which I can compile them. usually there are parts of code which have lots of errors in .Net 1.1 but it is fine code in 2.0 or later. So I am assuming they decompile to newer version of .Net than 1.1. Tools that I have already used are: Reflector, dotPeek, CodeReflect and some more. I need a tool which can decompile in 1.1 and I would be able to compile the same code in 1.1, it doesn't need to be free tool but I need to be able to save the code from it so I can compile it.

Thanks,

Ehsan
  • 1
  • 1
  • Out of curiosity, what are you doing that upgrading to 2.0 is not an option? – Scott Chamberlain Jun 20 '16 at 18:29
  • You could try to find a very old version of .NET Reflector, it's the first .NET decompiler AFAIK - the other ones were made after Red Gate's total failure at keeping their promise that the tool will remain free after they purchased it. – Lucas Trzesniewski Jun 20 '16 at 18:32
  • Company at this point doesn't want to upgrade since, new code is coming but meanwhile there are some changes that they prefer to do it in this version, and they don't want to test all single parts of the site. – Ehsan Jun 20 '16 at 19:41
  • We don't have any problem paying if the new version would do that. What I tried it is not working with new version of Reflector, you think older version works better? – Ehsan Jun 20 '16 at 19:43

1 Answers1

1

The chances are this assembly has been somehow modified (i.e. obfuscated, IL optimized, converted to .Net 2.0 etc.) after compilation.

Assuming the assembly was created in C# (would also be valid for VB though) it was created in C# 1.2. C# 2.0 came with .NET 2.0. So you are saying decompiling produces valid C# 2.0 code and invalid C# 1.2 code, i.e. the decompiled code employs language features introduced in C# 2.0 like generics, iterators, etc. However, all the new features brought in C# 2.0 are implemented kinda like IL macros, i.e. the compiler would generate a predefined piece of IL (in some cases entire methods or classes) for a given language feature. Hence these language features are decompiled by IL pattern matching, i.e. the decompiler looks for these very same specific compiler generated pieces of IL and converts them back to language features. It is highly unlikely that the C# 1.2 compiler will generate the same IL patterns, e.g. the IL generated by the C# 2.0 compiler for generics or iterators is pretty unique and the C# 1.2 compiler can hardly generate anything similar.

Try using JustDecompile on this assembly but do that on a machine where .net 1.1 is installed (having access to referenced assemblies helps the decompiler). If it fails the same way please provide a decompiled invalid C# 1.1 code sample

TsviatkoYov
  • 297
  • 1
  • 5