简体   繁体   中英

include XPathSelectElement in portable class library

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 .

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图标 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.

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

More details can be found here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM