.net – Software like DotPeek to decompile and edit DLL’s
Sorry for this newbie question, but after 3 hours of banging my head on a wall I just got DotPeek and I found it is PERFECT for looking into .dll files. However I can’t edit them at all. Is there free software like DotPeek that also lets me edit the DLL instead of just looking at it?
UPDATE: I was able to save all the .cs files in the .dll file separately and edit them in VS (Visual Studio). Now how do I get them back into the .dll file after editing?
Best Solution
Simpler method: You can use dnSpy to edit a managed DLL’s bytecode directly using the right click -> «Edit IL instructions» option and save the DLL back from File -> Save Module.

Related Solutions
C# – Visual Studio build fails: unable to copy exe-file from obj\debug to bin\debug
This is going to sound stupid, but I tried all these solutions, running VS2010 on Windows 7. None of them worked except the renaming and building, which was VERY tedious to say the least. Eventually, I tracked down the culprit, and I find it hard to believe. But I was using the following code in AssemblyInfo.cs.
[assembly: AssemblyVersion("2.0.*")]
This is pretty common, but for some reason, changing the version to 2.0.0.0 made things work again. I don’t know if it’s a Windows 7 specific thing (I’ve only been using it for 3-4 weeks), or if it’s random, or what, but it fixed it for me. I’m guessing that VS was keeping a handle on each file it generated, so it would know how to increment things? I’m really not sure and have never seen this happen before. But if someone else out there is also pulling their hair out, give it a try.
C# – Where to store external DLL files
This is what I do:
- Create a lib folder at the solution level
- Download and copy all my third-party DLL files into there
- Reference from the lib folder
- Put all those DLL files in the source control. I am using Subversion, and I add them manually but this is one-off.
You can also add a solution folder and add them there.
UPDATE 2012-12-19
The answer above was when NuGet was in infancy. FWIW, my approach where we have NuGet items:
- Do as above for plain DLL file dependencies (where they don’t have a NuGet pkg)
- Enable «Package Restore» for the solution
- Change packages.config file if needed to lock down the version to a particular package
- Do not store the package themselves in the version control system (set ignore for Git, Mercurial, etc.)
I actually use NuGet for managing even internal dependencies and have a private feed.
Как открыть dll файл как текст в c#?

Нужно открыть dll файл как текст, отредактировать его и сохранить обратно. После открытия стандартными средствами он читает только первые две буквы MZ, а потом ставит знак вопроса в треугольнике, хотя после mz идет куча всего. Как это сделать, например, с помощью того же notepad++, но через c#? Либо есть более удобный способ\библиотека?
- Вопрос задан более трёх лет назад
- 15888 просмотров
1 комментарий
Простой 1 комментарий
Software like DotPeek to decompile and edit DLL’s?
I just got DotPeek and I found it is PERFECT for looking into .dll files. However I can’t edit them at all. Is there free software like DotPeek that also lets me edit the DLL instead of just looking at it? UPDATE: I was able to save all the .cs files in the .dll file separately and edit them in VS (Visual Studio). Now how do I get them back into the .dll file after editing?
35k 9 9 gold badges 62 62 silver badges 83 83 bronze badges
asked Mar 21, 2016 at 19:57
301 2 2 gold badges 3 3 silver badges 8 8 bronze badges
4 Answers 4
Simpler method: You can use dnSpy to edit a managed DLL’s bytecode directly using the right click -> «Edit IL instructions» option and save the DLL back from File -> Save Module.

answered May 17, 2016 at 0:48
Samuel Katz Samuel Katz
24.3k 8 8 gold badges 71 71 silver badges 57 57 bronze badges
Great tool! Thanks for sharing!
Dec 10, 2019 at 9:43
Nice tool! They now have edit method, class and also support exporting as a project!
May 24, 2020 at 10:40
In the latest version of DotPeek you can right click on an assembly in the assembly explorer tree view and click the ‘Export To Project’ option. This will save it as an accessible Visual Studio solution and you can then make changes, debug in run time and recompile to replace the original DLL.
Remember it only provides this option for assemblies and not individual classes within an assembly.
answered Aug 22, 2017 at 2:49
5,926 5 5 gold badges 23 23 silver badges 44 44 bronze badges
This frequently breaks the assembly as it won’t be reconstructed perfectly
Dec 25, 2023 at 1:36
for minor IL code change, use dnSpy to modify the IL code is a easy way. for major .NET code change, use DotPeek to decompile the assembly and export it to a VS project. then you can edit the .cs code and rebuild from the new project.
Открыть старую dll
Есть старый ассет для Unity — последняя версия была для .NET 3.5 Ассет этот умеет рисовать текстуры на мешах, и делает это хорошо. Мне надо увеличить размер кисти — в оригинале он ограничен слайдером от 1 до 100, что делает невозможным рисование на больших объектах — кисть слишком маленькая. Я думал это поменять в скрипте, но, к сожалению, весь код вынесен в отдельную сборку .dll Я попытался открыть .dll DotPeek и .NetReflector, и оно успешно открывается, я даже без проблем нахожу нужный класс и переменную — brush.size Но что дальше? Кусок кода нужный мне выглядит примерно вот так
this.brush.size = GUI.Slider.value(0,100);
В идеале бы заменить его на
this.brush.size = GUI.Slider.value(0,10000);
и это бы скорее всего решило все мои проблемы. Но внутри самого DotPeek и Reflector ничего не меняется. Как поменять одну строчку и сохранить dll обратно? Если я выбираю экспорт проекта, он создает мне новый C# проект, внутри которого находятся и некоторые классы юнити, используемые этой сборкой, и классы самого ассета. И этот проект УЖЕ не компилируется, хотя только что был создан был декомпилером. Не находит часть типов, классов и ссылок на dll. Но как то он же жил без этого, находясь в сборке? Возможно, я стреляю из пушки по воробьям и поменять строчку можно быстрее и проще — но как это сделать? Может быть это можно сделать прямо во время выполнения.