include XPathSelectElement in portable class library

陌路散爱 提交于 2019-12-10 20:00:05

问题


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.


回答1:


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

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.


回答2:


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

More details can be found here.



来源:https://stackoverflow.com/questions/20651431/include-xpathselectelement-in-portable-class-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!