Reputation: 947
Using visual Studio 2012, creating a Portable Class Library project, I would like to use the XmlDocument class . However the library is not being found, even with
using System.Xml;
The error message is:
"are you missing a using directive or an assembly reference"
If I right click on References -> "Add References", browse to the dll directory (address below), and select the following dll:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.XML.dll
Then click OK, an error appears
"A reference to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.XML.dll' could not be added.
This component is already automatically referenced by the build system."
So a work around is to use an open source XML parsing library. Any suggestions ? Xerces ?
But it would be preferable to use the built in C# XmlDocument class.
Upvotes: 4
Views: 2359
Reputation: 1062780
Indeed, XmlDocument
is not available on all frameworks, hence may not be available in a PCL (depending on what framework options you have selected). However, the newer XDocument
generally is - try adding a reference to System.Xml.Linq.dll
if necessary.
The entire point of a PCL is that it restricts you to the strict subset of components available on all of the selected frameworks.
Upvotes: 2