Search code examples
c#wpfcompilationrecompile

How to modify existing program?


This is more of a blanket question than specific, but in my case I have a program I was given, but unfortunately it's broken. (It worked before, which was a while ago)

The program is a C# WPF .exe, but I'm just learning programming and I have no clue how to fix it. I can view the code behind it, I think, when I decompile it (dotPeek, but it seems to be read only), but I've no clue how to edit and recompile the program to work just like previously. I tried googling but I wasn't sure what terms would answer this question and the ones I've used proved fruitless.

Tl;dr - how to modify programs (especially C# WPF .exe)


Solution

  • Incorporated comments from @PaulF:

    Programs don't tend to break of their own accord - beyond getting corrupted - if that is the case then decompiling wont work. So you need to understand why it has stopped working - it is likely that a decompile & recompile will not work. What has changed from when it worked to when it stopped working (maybe operating system version or PC)? Can you go back to a state where it was working ?

    If that's not the issue, then:

    Do you have access to the source code? If not, you cannot make it work without re-writing it and re-deploying it, which isn't a bad thing. Then you would be able to have the source code and hopefully source control it.

    dotPeek allows you to see decompiled code, but you cannot do anything to the file safely.

    Those are about your only three options:

    1. Figure out what dependencies/configurations have changed
    2. Get the source and modify that
    3. Re-write it