How do I determine the exe filename at runtime?

  • Thread starter Thread starter nfr
  • Start date Start date
N

nfr

I have a Singleton Model object that can be instantiated by different
applications at runtime. This object activates a Channel using the config
file in its constructor, which needs the name of the config file as a
string.

Because the object does not know the application in which it is being
instantiated and because it's constructor is private, I need to know how to
determine the name of the default config file (i.e., filename.exe.config).

Does anyone know how I might do this?
 
Have you tried:
using System.Reflection;

...

System.Reflection.Assembly.GetCallingAssembly().CodeBase + ".config"

I looked into using Reflection but didn't see this one for some reason.
Thanks, that's exactly what I was looking for.
 
I take that back, it found the DLL it lives in but the the name of the .EXE
file that I am looking for.
 
Here's the problem. I have a DLL that ultimately lives withn an EXE of some
sort. I would like for that object to be able to discover the name of the
EXE in which it lives.
 
Back
Top