Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get assembly of method

Tags:

c#

reflection

Imagine the following situation:

Assembly A is starting the program. (it has a main method)

it loads Assembly B via reflection and instantiates a class of Assembly B.

in this instance a method is called where i would like to get to the Assembly B.

i have already tried

System.Reflection.Assembly.GetCallingAssembly();

System.Reflection.Assembly.GetExecutingAssembly();

but they always give me Assembly A instead of B.

like image 716
clamp Avatar asked Mar 03 '26 15:03

clamp


1 Answers

Try getting type of class contain the method you are going for and get its assembly.

string assemblyName = this.GetType().Assembly.FullName;
like image 142
Adil Avatar answered Mar 05 '26 06:03

Adil