How do I determine the exe filename at runtime?

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?
 
N

nfr

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.
 
N

nfr

I take that back, it found the DLL it lives in but the the name of the .EXE
file that I am looking for.
 
N

nfr

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top