Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding the executable name from managed dll, com-visible

I have created a managed dll and I would like to get the executable name it is attached to.... I have read this: How to get the executable path from a Managed DLL

It works fine with .net executables.... but when the dll runs under a com process, I don't have a .Net assembly... so Assembly.GetEntryAssembly() will return nothing....

Any ideas?

like image 757
Sam Avatar asked Dec 06 '25 17:12

Sam


1 Answers

How about:

using System.Diagnostics;
...
Process process = Process.GetCurrentProcess();
string name = process.ProcessName;
ProcessModule module = process.MainModule;
string path = module == null ? null : module.FileName;
like image 184
Marc Gravell Avatar answered Dec 08 '25 09:12

Marc Gravell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!