Change one cs file in C# dll

2019-09-14 17:05发布

I have no idea about C# programming.

My problem is that I have one DLL file consisting of many .cs files. One method implemented in one of those .cs files is written poorly and slowing down the whole application. I tried to decompile whole DLL with NET Reflector and succeed but with 14 errors. Then I improved my one .cs file and tried to compile all .cs back to .DLL once again. As you suspect, I ended with more that 100 compilation errors in Visual Studio. I assume this is happening because of poor quality of the decompiled code.

Is there anything that I can do with it without spending 1000 hours to learn C#, understanding all 10MB of source .cs files, rewriting them and compiling back to DLL?

标签: c# .net dll
2条回答
贪生不怕死
2楼-- · 2019-09-14 17:36

if you still looking to change dll, instead of extending the class, you can use IL spy with reflexil.

  • this allows you to change the dll and save it.
  • you can make small changes to the DLL easily.
查看更多
疯言疯语
3楼-- · 2019-09-14 17:40

You can't change a .cs-File in a DLL, because a DLL does not consist of files, but IL code instead - at least, when you talk about a .Net-Library.

You can decompile the DLL, change the code and recompile it, but decompiled code probably won't be able to be compiled again, depending on what exactly the original code contained.

If there is no source available for the DLL, you will probably not be able to change the way a DLL behaves.

You may try to extend the class in a DLL by inheritance and use your "Updated version" instead.

查看更多
登录 后发表回答