System.Xml is needed for no reason.

protected override DataTable internalExecuteTable(string SQL) { DbDataReader reader = ExecuteReader(SQL); DataTable dt = new DataTable(); dt.Load(reader); reader.Close(); return dt; } 

The "internalExecuteTable" is underlined and gives the error message "System.Xml", and I have to add the link "System.Xml". But why?

I use the above code to read from a SQLite database (System.Data.SQLite wrapper)

+4
source share
2 answers

You are using indirectly System.Xml . DataTable has dependencies on the classes defined in the System.Xml assembly. If you look at the documentation for this class or just learn it in your IDE, you will notice that it includes many methods for reading and writing XML, for example.

Using System.Data.DataTable , you also need to specify System.Xml .

+10
source

DataTable according to MSDN , declared as

 [SerializableAttribute] public class DataTable : MarshalByValueComponent, IListSource, ISupportInitializeNotification, ISupportInitialize, ISerializable, IXmlSerializable 

IXmlSerializable declares methods that use XmlReader , XmlWriter and XmlSchema for input or output, all of which are declared respectively in System.Xml.dll.

If you are immersed in code (using official sources or IL / Decompiler), you may notice the use of the attribute:

 [XmlSchemaProvider("GetDataTableSchema")] //... public class DataTable : //... 

Unfortunately, the guys at MSDN did not explicitly indicate this link to System.Xml in the comments section - perhaps because regular project templates include this anyway.

0
source

All Articles