Oleg Vazhnev
Oleg Vazhnev

Reputation: 24067

is it any difference between executing class from project and class from class library?

Assume I have some class in my project. Now I create another "Class library" and move this class there. So to instatiate this class now extra dll (class library dll) need to be loaded.

I understand that now I have a little bit another program because now .net need to read two files (original exe file + class library dll file) instead of just one exe file. But other than that are there any difference? After the program is loaded is it important where this class was located originally (exe or dll)? Will I have absolutely the same program in memory?

In particular I'm interested if I can introduce any delays at runtime moving my class to class library?

This question is result of my previous question how to separate several "a little bit connected" projects?

Upvotes: 0

Views: 87

Answers (2)

Jakub Konecki
Jakub Konecki

Reputation: 46008

Premature optimisation is the root of all evil. - don't think that you can improve performance of your application by putting all code in one assembly. Maintenance gain is far more important than additional hit of loading another file into memory by CLR.

Upvotes: 2

Eric J.
Eric J.

Reputation: 150138

After the DLL is loaded into the memory space of your process, there should be no difference in performance compared to if the same code had been included in your EXE project instead.

In fact, you will probably see a performance gain over the long run by having common code in a dedicated place. If you tend to put common code into your main projects, you are likely to end up with substantial duplication of code, leading to both maintenance headaches and ultimately a larger memory footprint for your more complex applications).

Upvotes: 3

Related Questions