3
votes

How can I use XPathSelectElement in a portable class library? When I try to include System.Xml.XPath assembly in the project, I get the following error:

The type 'System.Xml.Linq.XElement' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xml.Linq, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

My portable class libraries already have a reference to System.Xml.Linq.

2

2 Answers

1
votes

Unfortunately, MSDN is showing that, as of .NET 4.5, these extension methods are not supported in Portable Class Libraries. If they were supported, they would display a PCL icon image. However, it looks like Microsoft did provide a Nuget package that provides at least some of the functionality in the System.Xml.XPath namespace.

0
votes

Because XPathSelectElement is declared in System.Xml.Linq.dll, you should also reference it.

More details can be found here.