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?
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
.
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:
The error may be misleading if you have the reference - you may also need to reference System.Xml.Serialization
.