It just doesn't work??

Explore, browse and analyze .NET assemblies

Moderators: Luke Jefferson, Charles Brown, StephenC, Alex.Davies, Greg.Tillman, melvyn.harbour

It just doesn't work??

Postby conspiritor » Thu Sep 30, 2010 6:08 pm

From VS2008, I select "Choose Assemblies to Debug."
I check an assembly and click "Okay."
So it finished it successfully.

Now when I go to right click on class in my project that came from disassembled dll it opens disassembled .cs file and not some file from meta data that it was opening before disassembling, which tells us that disassembling process went well...

So now I wand to modify that code and see changes in my project.

So I modified(added couple of attributes in one of classes) disassembled .cs file and saved ti.

But I cant see any of changes in my project like it is still using old(not disassembled .dll)?

What have I done wrong?
conspiritor
 
Posts: 6
Joined: Thu Sep 30, 2010 5:48 pm

old pdb files?

Postby jericsmith » Fri Oct 01, 2010 3:13 am

Did you check for and clear your old pdb files from your bin folder and/or referenced assemblies' folders?
jericsmith
 
Posts: 3
Joined: Fri Oct 01, 2010 3:09 am

Postby Bart Read » Fri Oct 01, 2010 3:02 pm

Hi there,


Just to clarify before I go into more detail: are you trying to modify the assembly you decompiled by editing and recompiling the decompiled source code?


Thanks,


Bart
Bart Read
Principal Consultant
bartread.com Ltd
Bart Read
 
Posts: 977
Joined: Thu Mar 31, 2005 11:17 am
Location: Cambridge, UK

Postby conspiritor » Fri Oct 01, 2010 10:35 pm

Thanks for quick respond!

Yes, I have deleted all .pdb files from all folderis in my project.

Yes, that's what I want....
conspiritor
 
Posts: 6
Joined: Thu Sep 30, 2010 5:48 pm

my process

Postby jericsmith » Sat Oct 02, 2010 2:36 am

Bart probably has a better solution. I'm a newbie with this, but I am in the process of decompiling some assemblies that are internal to my company but inaccessible to me as source. This is the process that has been working for me:

1. From Reflector, I select an assembly.
2. I select File|Export and save the disassembled project to a known location.
3. I clean up the disassembled source code, because Reflector doesn't do a compilable disassembly (so far anyway). I have to go in and change method calls back to property calls and other little things like that.
4. Once the project is clean and compilable, I import it into my solution.
5. I change my project references from the previous assembly to my newly disassembled project.
6. Voila!

If there is an easier way, somebody please fill me in.
jericsmith
 
Posts: 3
Joined: Fri Oct 01, 2010 3:09 am

Postby conspiritor » Sun Oct 03, 2010 3:43 pm

Well I tried what you did, but I can't see export option in file tab so i manually navigate to folder where disassembled files are and copy them to known location.

So I import whole folder in visual studio as to create dll library project.

But I never managed to compile it, since it always reports a lot of errors...

So any other method for recompiling modified disassembled dlls would be nice...?
conspiritor
 
Posts: 6
Joined: Thu Sep 30, 2010 5:48 pm

a lot of errors reported

Postby jericsmith » Sun Oct 03, 2010 6:58 pm

I'm using the standalone reflector application, but as long as you ultimately end up with the source, that's ok.

Yes, there are a lot of errors. I've corrected as many as 2000+ in a single project; however, it's not as bad as it seems. Most of the errors can be fixed several at a time. For example:

do a global "current project" replace of get_Value() to Value. Many others similar to this will exist as well, like get_Attributes(), get_Count(), etc.

method calls use literal values for an expected enumeration; CommandType.StoredProcedure is passed as the literal value 4, but you can replace enough of the function call to make sure you are replacing the correct parameter. For example, I was able to correctly search for
Code: Select all
this.ExecuteDataset(transaction, 4, spName,
and replace with
Code: Select all
this.ExecuteDataset(transaction, CommandType.StoredProcedure, spName,


It's a bit of work, but not as bad as it seems when you first try to compile.

Again, if there is an easier way, I would love to hear about it, but so far this method has served my purpose, albeit with tedium.
jericsmith
 
Posts: 3
Joined: Fri Oct 01, 2010 3:09 am

Postby conspiritor » Sun Oct 03, 2010 9:18 pm

Yes but it can be really hard if you are not experienced enough though.

You can also have problems if you correct something "wrongly" so admins any alternative method??
conspiritor
 
Posts: 6
Joined: Thu Sep 30, 2010 5:48 pm

Postby Bart Read » Tue Oct 05, 2010 1:26 pm

Hi there,


Yes, I'm afraid jericsmith is right: you'll need to manually correct the compilation errors. Unfortunately .NET Reflector's decompilation is not perfect, which is something I've written at length about elsewhere (http://www.simple-talk.com/community/blogs/bart/archive/2009/07/30/74203.aspx) so I won't go into any detail here.

We do obviously keep improving it but, just because of the nature of the problem, it's extremely unlikely that it will ever be possible to do a perfect decompilation that recompiles first time with no errors, except for very simple applications.

BUT if all you want to do is tweak the assembly in question by adding a couple of attributes here and there, I'd suggest you take a look at the Reflexil add-in, which will allow you to edit the assembly without needing to completely decompile it. You can find Reflexil here:

http://sebastien.lebreton.free.fr/reflexil/

I hope that's helpful.


Thanks,


Bart
Bart Read
Principal Consultant
bartread.com Ltd
Bart Read
 
Posts: 977
Joined: Thu Mar 31, 2005 11:17 am
Location: Cambridge, UK

Postby conspiritor » Tue Oct 05, 2010 4:23 pm

Thanks Bart,

Can I make minor changes in dll without completely decompiling it just using Visual Studio addon?

Is that supported?
conspiritor
 
Posts: 6
Joined: Thu Sep 30, 2010 5:48 pm

Postby Bart Read » Tue Oct 05, 2010 4:26 pm

Hi again,


Unfortunately not. The VS add-in is designed to allow you to debug through code but obviously, due to the issues with decompilation, recompiling it is not straightforward.

Hence the combination of the standalone .NET Reflector, along with the Reflexil add-in, which is also free, is probably your best option. Once you've downloaded Reflexil you can install it via the View > Add-ins main menu item in .NET Reflector.

Hope that helps!


Thanks,


Bart
Bart Read
Principal Consultant
bartread.com Ltd
Bart Read
 
Posts: 977
Joined: Thu Mar 31, 2005 11:17 am
Location: Cambridge, UK

Postby conspiritor » Tue Oct 05, 2010 6:08 pm

Ok, thanks man...

I don't want to be annoying, but are you planing to add that feature in further releases?
conspiritor
 
Posts: 6
Joined: Thu Sep 30, 2010 5:48 pm

Re:

Postby Bart Read » Wed Oct 06, 2010 12:32 pm

conspiritor wrote:Ok, thanks man...

I don't want to be annoying, but are you planing to add that feature in further releases?


No problem. To be honest, I really couldn't say. It's not something we've considered so far.
Bart Read
Principal Consultant
bartread.com Ltd
Bart Read
 
Posts: 977
Joined: Thu Mar 31, 2005 11:17 am
Location: Cambridge, UK


Return to .Net Reflector 6.x and .NET Reflector 6.x Pro

Who is online

Users browsing this forum: No registered users and 1 guest