سؤال

I inherited a bit of legacy code that was originally written in VS .NET 2003. I'm familiar with how ConfigurationManager works in newer versions of .NET, and have used it successfully to grab connections strings from the web.config. My problem is that this code does not seem to be pulling from the web.config at all, and utilizes a namespace I'm not familiar with.

Here is the relevant code:

using Microsoft.ApplicationBlocks.ConfigurationManagement;

public class ConfigurationBlock
{
    private static Hashtable GetSection()
    {
        HashTable configBlock = ConfigurationManager.Read();
        return configBlock;
    }
}

When I follow this code, it successfully pulls a huge list of data from ...somewhere. Is there a way to set where ConfigurationManager is pointing to that I'm not aware of, either programmatically or through the VS2003 interface? Any help would be greatly appreciated.

هل كانت مفيدة؟

المحلول

The namespace is referring the Microsoft application blocks ( set of utilities) so if you have to use the Microsoft application blocks, you have to download and install it, and then reference the dll. However , in order to read values from web config or app config you can use

class:      ConfigurationManager 
Namespace:  System.Configuration
Assembly:  System.Configuration (in System.Configuration.dll)
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top