How to get the folder my classlibrary is located in

  • Thread starter Thread starter PEACEMAKER
  • Start date Start date
P

PEACEMAKER

I'm writing a custom config file for my classlibrary dll. However when I try
to load the config file the directory it points to is the folder of the
application that called the dll. Is there a way to get the folder location
where my dll is installed in, from the dll itself?
 
You can call Assembly.GetExecutingAssebly().Location from your dll to get its path.

If you're using the stock configuration classes that ship with the .NET framework (i.e. System.Configuration.ConfigurationSettings.AppSettings["whatever"]), you'll always get the configuration file for the main application (.exe), no matter what library you're calling from, since it's an application config file, not a library config file. If you can't keep the library config options with the rest of the app's options, you'll have to roll your own solution for keeping config information.
 

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

Back
Top