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
0

Comments

12 comments

  • jericsmith
    Did you check for and clear your old pdb files from your bin folder and/or referenced assemblies' folders?
    jericsmith
    0
  • Bart Read
    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
    0
  • conspiritor
    Thanks for quick respond!

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

    Yes, that's what I want....
    conspiritor
    0
  • jericsmith
    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
    0
  • conspiritor
    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
    0
  • jericsmith
    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
    this.ExecuteDataset(transaction, 4, spName,
    
    and replace with
    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
    0
  • conspiritor
    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
    0
  • Bart Read
    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
    0
  • conspiritor
    Thanks Bart,

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

    Is that supported?
    conspiritor
    0
  • Bart Read
    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
    0
  • conspiritor
    Ok, thanks man...

    I don't want to be annoying, but are you planing to add that feature in further releases?
    conspiritor
    0
  • Bart Read
    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
    0

Add comment

Please sign in to leave a comment.