最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】VB.Net中出错:XML literals and XML axis properties are not available. Add reference to System.xml System.xml.linq and System.Core

VB.Net crifan 2390浏览 0评论

【问题】

在折腾:

【已解决】VB.Net中的多行字符
的过程中,结果出错:

XML literals and XML axis properties are not available. Add reference to System.xml System.xml.linq and System.Core

XML literals and XML axis properties are not available. Add reference to System.xml System.xml.linq and System.Core

【解决过程】

1.对于

System.xml

System.xml.linq

System.Core

我知道是属于.Net 4.0中的,因为之前折腾过C#而知道的。

而我刚才建VB.Net项目时,也的确选择是.Net 2.0.

2.此处就是想办法,想去把.Net 2.0改为.Net 4.0.

本以为,可以像C#中,去属性中就可以改了,结果却发现,VB.Net的项目的属性中:

right click propertiy

结果竟然没有对应的.Net选项:

application no dotnet

所以,没法简单的更改。

3.貌似只能重新建一个.Net 4.0的VB.Net了:

file new project

new .net 4.0 project

donet 4.0 new one

4.结果又出错了,详见:

【已解决】VB.Net中导入System.Core出错:Namespace or type specified in the Imports System.Core doesnot contain any public member or cannot be found

5.然后代码就正常了:

class XElement Represents an XML element

class XElement Represents an XML element

 

【总结】

确保当前的VB.Net是4.0的,然后使用:

Imports System.Xml
Imports System.Xml.Linq

然后就可以使用类似于:

Dim s As String = <a>Hello
World</a>.Value

的方式去定义多行字符串了。

转载请注明:在路上 » 【已解决】VB.Net中出错:XML literals and XML axis properties are not available. Add reference to System.xml System.xml.linq and System.Core

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
84 queries in 0.159 seconds, using 21.93MB memory