views:

138

answers:

1

I have created a managed dll and I would like to get the executable name it is attached to.... I have read this: http://stackoverflow.com/questions/121116/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?

A: 

How about:

using System.Diagnostics;
...
Process process = Process.GetCurrentProcess();
string name = process.ProcessName;
ProcessModule module = process.MainModule;
string path = module == null ? null : module.FileName;
Marc Gravell