Click here to Skip to main content
15,798,200 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guru,
I am newbie programmer with the little experience and having some knowledge of C# and
I am currently assigned to make the changes for some pages of the C# window application that is using Webservice (C# 4.0, .Net Framework 4.0). I don't have the source code for the project but exe and dll files only (a few dll files in bin folder and 3 exe files, a few .resx files, .asmx files and web config outsides of the bin).

After searching through the google, I understand that I need to used the reflector tools to decompile the code and reflexil plugin to change the code. I have decompiled all of the exe and dll files of the application and lastly I got the source code with a lot of errors. However, I don't see any design page and don't have any idea whether the solution structure is correct or not since I have not seen the source code before at all.I really need the help from you.I would like to get the correct source code and solution structure.

It would be deeply appreciated if someone can tell me
1) What is the proper way to decompile ? (Do I need to decompile both exe files and dll or either one?)
2) Which is the better way to change the code? (via reflector with reflexil or Visual Studio)
3) May I have some links that explain well how to convert the decompiled code (auto-generated code) to the correct source code?
4) How shall I do in order to get design page (all I see is .cs page)?
5) How to check the current solution structure is correct or not?

Please let me know if any further information is required to provide.
Thank you so much in advance for your kind advice.

Note:The previous programmer left the company and don't have the source code.
Updated 16-Jul-18 3:00am
Kaysikarline 10-Jan-14 0:01am    
Referring to Q3:
How to edit the decompiled code?
For example, I have the decompiled code as follows:
private bool MoveNext()
switch (this.<>1__state)
case 0:
this.<>1__state = -1;
this.<count>5__1 = 0;
while (this.<count>5__1 < 10)
this.<>2__current = this.<count>5__1;
this.<>1__state = 1;
return true;
this.<>1__state = -1;

case 1:
goto Label_004B;
return false;
Do I need to change that as below?
static IEnumerator GetCounter()
for (int count = 0; count < 10; count++)
yield return count;
GKP1992 16-Jul-18 8:06am    
You should not stay where you are working right now. Leave asap.

I've always had problems with decompiling and Reflector, try DotPeek[^].

1. You only really need to decompile the one you need to modify. If you change an API in the DLL it may require you to change the EXE.

2. There are tools out there that let you work directly on MSIL and modify inside the tool, but I would prefer to go back to code and recompile the entire thing. The "best" one is the one that works in your situation with the least amount of effort.

3. I'm not sure what you mean "correct" source code. If you mean the code without errors, try the tool I linked above. It will convert to C# and people have had good results with it. No tool is 100% effective though since the compiler may include optimizations that are not possible to replicate in source.

4. A lot of decompilers (Reflector is one with this problem) doesn't make separate Designer.cs files. I'm not sure if DotPeek will create designer files but there isn't a good way around this. Designer files exist for the pure reason to make it easier to separate designer code from user code, after it runs through the compiler its impossible to determine if it was designer generated or user generated.

5. The solution structure is the one that compiles, technically folders and internal structure of the solution are only there to make it easy to organize code, and again, this structure is not replicated in the compiled file. The decompiler has no way of knowing how this was laid out (it can guess based on namespaces), but there is no way to duplicate the original structure. As long as all the files are there and compiles back into the right namespaces and types, its as good as you can hope for.
Share this answer
Kaysikarline 10-Jan-14 0:02am    
Really thank you so much for your kind answer. For the question No.3, I have updated as above.
Ron Beyer 10-Jan-14 0:09am    
I would try opening it in DotPeek (free by the way) and see if you get a better decompilation. What you posted is pretty classic of compiler optimizations that are difficult to put back into code. Typically with an enumerator you need to have a yield return somewhere in there, although the prototype of the method should not change (bool MoveNext to GetCounter), it really depends on what you are trying to do.
Kaysikarline 10-Jan-14 0:12am    
Thank you so much. I will try with dotPeek.
Kaysikarline 19-Jan-14 11:48am    
I have tried with dotPeek and it is better than reflector although it is not 100% effective as you mentioned. I have cleared a lots of errors. But I am still struggling for UI. Thank you so much!!
Kaysikarline 20-Jan-14 3:43am    
Dear Guru,
I have been searching through Google few days ago to edit the UI that is embedded in DLL. Unfortunately, I don't find any exact answer for that. Is it possible to edit the UI that is embedded in DLL (reference class library) from current console application in C#? For a example updating Drop Down List. If yes, may I have some tutorial links to update them?

Thank you so much in advance.
I have done such things in the past….
Source Code was lost - only the binaries left.

I started with creating a new Project (Windows application, .NET 4 in your case).
Then tried to fill up with the decompiled code -piece by piece. Hopefully you will find out that maybe there is no need to decompile the dlls because you don't have to change anything there.

So at least you end with something managable for the future...
Share this answer
Richard MacCutchan 16-Jul-18 8:18am    
Look at the date of this question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900