How can I make a .NET class library read its own configuration file?

前端 未结 7 811
予麋鹿
予麋鹿 2020-12-13 15:10

I have a .NET class library that provides a set of helper functions that are used by several Web Services. This class library must store a single setting, specifically, a co

相关标签:
7条回答
  • 2020-12-13 16:01

    I think you're looking for:

    ConfigurationManager.OpenExeConfiguration(string exePath)
    

    or

    ConfigurationManager.OpenMappedExeConfiguration(
        new ExeConfigurationFileMap() { 
            ExeConfigFilename = path + "app.config" 
        }, ConfigurationUserLevel.None);
    

    Which returns a Configuration object. MSDN doc on ConfigurationManager

    Try this question for how to get the DLL path.

    0 讨论(0)
提交回复
热议问题