Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between GetEntryAssembly and GetExecutingAssembly

I've read docs for GetEntryAssembly and GetExecutingAssembly trying to make sense of the difference between them. I simply fail to understand how the definitions relate to each other. Altough I see two different formulations, I can't understand the distinction implied. In my head, it's a potayto-potahto situation, which is reinforced by the same contents on my screen when I try to display the values of each returned Assemby object.

Naturally, there must be some difference and it's simply my competence that prevents me from realizing what it is. So I've done some research, only discovering that most of the wisdom out there is about obtaining the path. The lonely resource that was explicitly targeting the comparison between them was here.

Can I ask for a specific example where those two methods return objects the contents of which differ? Preferably with a brief explanation of why.

like image 228
Konrad Viltersten Avatar asked Nov 21 '25 04:11

Konrad Viltersten


1 Answers

Let's say you have a console project MyConsoleProject that references library project MyLibrary.

Inside MyConsoleProject both Entry and Executing assemblies will be the same. But inside MyLibrary the ExecutingAssembly will refer to library project, not the console one.

like image 50
Tomas Chabada Avatar answered Nov 23 '25 18:11

Tomas Chabada