Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the executable path from a Managed DLL

I have a managed DLL (written in C++/CLI) that contains a class used by a C# executable. In the constructor of the class, I need to get access to the full path of the executable referencing the DLL. In the actual app I know I can use the Application object to do this, but how can I do it from a managed DLL?

like image 865
Brian Stewart Avatar asked Dec 01 '22 13:12

Brian Stewart


1 Answers

Assembly.GetCallingAssembly()

or

Assembly.GetExecutingAssembly()

or

Assembly.GetEntryAssembly()

Depending on your need.

Then use Location or CodeBase property (I never remember which one).

like image 173
leppie Avatar answered Dec 06 '22 10:12

leppie