System.NullReferenceException: Object reference not set to an instance
of an object.
Am getting this error whenever am trying to read the xml file.
public static DataSet orads;
String path = Directory.GetCurrentDirectory();
path = path + "\\Mailconfig.xml";
orads.ReadXml(path);
I placed the xml file in bin folder of the application.
I couldnt find what mistake I made.
you haven’t initialized
orads, you have just declared it, that is why you are getting the exception.The following line only declare a
DataSetit has not been assigned any value. Currently it is holdingnullLater you are calling an instance method
ReadXmlonnullobject that is why you are getting the exception.You need to instantiate it before using.
Or you may instantiate it with declaration.