I can add the statement using System.Configuration; to my code using intellisense, but I can’t get any intellisense when I access the type ConfigurationManager.
Why does intellisense work when entering the using directive, but doesn’t work when specifying a type from that namespace?
using System.Configuration;
namespace TestDBMSConnection
{
class Program
{
static void Main(string[] args)
{
var dataProviderName = ConfigurationManager.AppSettings["provider"];
}
}
}
I can fix the issue by adding a reference to System.Configuration, but I don’t understand why I don’t need to do that for intellisense to work for the using directive.
Classes in a namespace are not required to be located in the same assembly.
Some classes in the System.Configuration namespace are located in System.dll (such as SettingsBase) while some other classes are located in System.Configuration.dll (such as ConfigurationManager).
IntelliSense can only suggest classes and namespaces in referenced assemblies. So if you have System.dll referenced but not System.Configuration.dll, IntelliSense can suggest the System.Configuration namespace and the System.Configuration classes located in System.dll, but not those located in System.Configuration.dll.
IntelliSense can also not know in which unreferenced assembly a certain class might be located. So you have to reference System.Configuration.dll manually before you can use it.