Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a compile error in c# about not referencing System.XML, yes System.XML is being reference

I am trying to add a new feature to an old program I wrote. However, when trying to get the program to build in VS express it spits back an error message to me.

Error 1 The type 'System.Xml.Serialization.IXmlSerializable' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. C:\Path\To\File\summaryForm.cs 101 18 SerialController

However the thing is at the top of the cs file, it has

using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms; 
using System.Xml;

Any ideas whyits not recognizing the XML reference?

like image 206
needoriginalname Avatar asked Aug 05 '15 14:08

needoriginalname


2 Answers

Using a namespace does not mean you referenced something. You need to add a reference to System.XML.

If you are using Visual Studio, right click on references, click Add Reference and then select System.XML.

like image 156
nvoigt Avatar answered Oct 17 '22 23:10

nvoigt


The using directive (not to be confused with the using statement) is just to import namespaces from your referenced assemblies into your code file in order to make it easier to use the types that the assemblies contain without having to fully-qualify their names with their namespaces. The fact that the assembly System.Xml and the namespace System.Xml are named the same, in this case, is merely a coincidence.

You need to actually add the System.Xml.DLL reference, as it suggests, to your project: right-click on "References" beneath your project in the solution explorer, select "Add Reference", then locate and check off the System.Xml assembly within the list of framework assemblies:

enter image description here

enter image description here

like image 44
rory.ap Avatar answered Oct 17 '22 23:10

rory.ap