Link to a large DLL for one method

I want to use one method from a large library DLL in C #.

Are there any performance flaws or something else?
Should I β€œread” the method code with the reflection tool and copy it into my project?

Update: Hard disk space is not a problem. My application is a web application.

+4
source share
4 answers

Are there any performance flaws or something else?

The only thing that really matters is the size of your distribution, if that matters to you. (Users upload a 30 MB file instead of 2 MB). The differences in performance will be minor. Assembling the binding and checking the strong name (if signed) hash may take longer, but is unlikely to be noticeable to the user.

Should I β€œread” the method code with the reflection tool and copy it into my project?

Probably no; most licensing conditions prohibit reverse engineering and / or only partial distribution. Check your license, if you have one, to see if you can even do this first.

+7
source

No, leave this up to the JIT compiler. It is already selective that IL actually turns into machine code, it only compiles what is actually being executed. You will lose some virtual address space, but it costs nothing, it is virtual. You do not pay for what you do not use.

+3
source

Costs are disk space, boot time, and memory size. The JIT compiler will only compile what you call (there may be caveats, but of course it will not compile the entire assembly). This is your call about whether you should "break" the method you need. Remember, of course, that it could be a rabbit hole, so I mean that this method will probably use other classes in its assembly, so it may not be as easy as you think to extract the necessary code.

+1
source

Ba, extreme hacking needs in extreme cases. The code of the copying methods (if possible) is an extreme hack, imo.

  • If it’s just a disappointment to use unnecessary memory, but basically a fairly affordable solution, do it as if you were continuing to do so. Simple and easy.

  • If there are memory problems and the method is not called too often (which too often depends on your project), you can try loading it into an external AppDomain and upload this domain once when you are done with it. In this case, you need to take care of the IPC manual. There is nothing free in this world.

  • You can try to do what you wrote. User Reflector (or similar software), get the C # method code and create its clone. All this suggests that this method does not use the internal structures of the DLL, state, or anything else, so in this case the story becomes quite complicated.

Good luck.

+1
source

Source: https://habr.com/ru/post/1387595/


All Articles