0

I am using the ConfigurationManager in a Class Library and I want to read the config file for the Class Library project. The ConfigurationManager wants to read the config file for the applicaiton. How do I read the Class Library config file?

<html>
Dim strCBFile = ConfigurationManager.AppSettings("CBFile")
</html>

2
Contributors
2
Replies
4
Views
8 Years
Discussion Span
Last Post by TheBrenda
0

I hope this will help you:

Dim myMap As New ExeConfigurationFileMap
myMap.ExeConfigFilename = "MyConfigFile.exe.config"
Dim cs As Configuration = ConfigurationManager.OpenMappedMachineConfiguration(myMap)
0

This worked for me. I still need to know the path for the config, but I can use the .Net config file set up in the IDE for the class library.

The previous post returned the machine config. This is not what was needed.

Dim strConfig As String = "C:\Code\dot NET\CCMC\AppComm\BytePro\ByteProToCBInvoker\bin\Debug\ByteProToCBInvoker.dll"
        Dim config As System.Configuration.Configuration = ConfigurationManager.OpenExeConfiguration(strConfig)
        Dim csSection As AppSettingsSection = config.AppSettings

        Dim strDBPath As String = csSection.Settings("DBPath").Value
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.