How to read a user setting in another project?

W

Wayne

There are two projects in my solution, one is utility dll and the
other is the main executable. I have user settings in the exe project.
However I want to read the settings in the utility dll so that the
utility dll can be reused in other projects but generate project-
specified results. The scenario would be

namespace dll
{
static class StringGenerator
{
static public string ProjectSpecifiedString()
{
return String.Format("{0} is project specified.",
Assembly.GetExecutingAssembly()... /*The answer to my question!*/);
}
}
}
 
I

Ignacio Machin ( .NET/ C# MVP )

There are two projects in my solution, one is utility dll and the
other is the main executable. I have user settings in the exe project.
However I want to read the settings in the utility dll so that the
utility dll can be reused in other projects but generate project-
specified results. The scenario would be

namespace dll
{
  static class StringGenerator
  {
     static public string ProjectSpecifiedString()
     {
       return String.Format("{0} is project specified.",
Assembly.GetExecutingAssembly()... /*The answer to my question!*/);
     }
  }



}- Hide quoted text -

- Show quoted text -

You can access the configuration and the settings from any project. it
can be only defined in the "main" project.
A little explanation.
The ConfigurationManager is a static class so it's available to ANY
class in the AppDomain and it will be the same isntance. As your dll
runs in the same AppDomain than the code that included and loaded the
configuration you can use it.
 

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