Red Gate forums :: View topic - It just doesn't work??
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
.Net Reflector 6.x and .NET Reflector 6.x Pro
.Net Reflector 6.x and .NET Reflector 6.x Pro forum

It just doesn't work??

Search in .Net Reflector 6.x and .NET Reflector 6.x Pro forum
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.
Jump to:  
Author Message
conspiritor



Joined: 30 Sep 2010
Posts: 6

PostPosted: Thu Sep 30, 2010 6:08 pm    Post subject: It just doesn't work?? Reply with quote

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?
Back to top
View user's profile Send private message
jericsmith



Joined: 01 Oct 2010
Posts: 3

PostPosted: Fri Oct 01, 2010 3:13 am    Post subject: old pdb files? Reply with quote

Did you check for and clear your old pdb files from your bin folder and/or referenced assemblies' folders?
Back to top
View user's profile Send private message
Bart Read



Joined: 31 Mar 2005
Posts: 978
Location: Cambridge, UK

PostPosted: Fri Oct 01, 2010 3:02 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
conspiritor



Joined: 30 Sep 2010
Posts: 6

PostPosted: Fri Oct 01, 2010 10:35 pm    Post subject: Reply with quote

Thanks for quick respond!

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

Yes, that's what I want....
Back to top
View user's profile Send private message
jericsmith



Joined: 01 Oct 2010
Posts: 3

PostPosted: Sat Oct 02, 2010 2:36 am    Post subject: my process Reply with quote

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.
Back to top
View user's profile Send private message
conspiritor



Joined: 30 Sep 2010
Posts: 6

PostPosted: Sun Oct 03, 2010 3:43 pm    Post subject: Reply with quote

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...?
Back to top
View user's profile Send private message
jericsmith



Joined: 01 Oct 2010
Posts: 3

PostPosted: Sun Oct 03, 2010 6:58 pm    Post subject: a lot of errors reported Reply with quote

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:
this.ExecuteDataset(transaction, 4, spName,
and replace with
Code:
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.
Back to top
View user's profile Send private message
conspiritor



Joined: 30 Sep 2010
Posts: 6

PostPosted: Sun Oct 03, 2010 9:18 pm    Post subject: Reply with quote

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??
Back to top
View user's profile Send private message
Bart Read



Joined: 31 Mar 2005
Posts: 978
Location: Cambridge, UK

PostPosted: Tue Oct 05, 2010 1:26 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
conspiritor



Joined: 30 Sep 2010
Posts: 6

PostPosted: Tue Oct 05, 2010 4:23 pm    Post subject: Reply with quote

Thanks Bart,

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

Is that supported?
Back to top
View user's profile Send private message
Bart Read



Joined: 31 Mar 2005
Posts: 978
Location: Cambridge, UK

PostPosted: Tue Oct 05, 2010 4:26 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
conspiritor



Joined: 30 Sep 2010
Posts: 6

PostPosted: Tue Oct 05, 2010 6:08 pm    Post subject: Reply with quote

Ok, thanks man...

I don't want to be annoying, but are you planing to add that feature in further releases?
Back to top
View user's profile Send private message
Bart Read



Joined: 31 Mar 2005
Posts: 978
Location: Cambridge, UK

PostPosted: Wed Oct 06, 2010 12:32 pm    Post subject: Re: Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
This topic is locked: you cannot edit posts or make replies. All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group