views:

20

answers:

1

I have a DLL. from which I would like to get the app's name. The following code, called from the DLL, returns the DLL's full name:

string assemblyFullUncPath = 
    System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;

...so it isn't quite what I'm after. I could add an Assembly parameter, but I'd prefer not to. Is it possible?

A: 

Try Assembly.GetEntryAssembly().

Andrey Shchekin
Of course, I should have looked into that. Thanks for the reply!
Gregg Cleland
Just make sure that you understand that this method might *not* return the actual executable (as in EXE) that has been used to start the process. This happens when you call that operation from an appdomain other than the default domain. If you are writing some utility functionality that should be agnostic of its environment, you might want to keep that in mind (it has bitten me once ;-)
Christian.K