2015-12-14 41 views
4

Visual Studio支持XML IntelliSense for Visual Basic(它建議您鍵入時的XML元素和屬性名稱)。我正在嘗試使用VS 2015來更新我幾年前在VS 2012或2013年開始的項目。該項目使用XML,並且我已經設置爲使用XML IntelliSense。該項目在VS 2015下編譯並運行正常,但XML IntelliSense不起作用(不提供元素名稱)。如何在VS 2015中使用XML IntelliSense?

要嘗試解決問題,我創建了下面的XML文件(保存爲Test.xml在我的文檔):

<?xml version="1.0" encoding="utf-8"?> 
<Root xmlns="http://www.finetime.com"> 
    <Parent> 
     <Child>Data</Child> 
    </Parent> 
</Root> 

我創建了一個新的Windows窗體項目有一個按鈕Button1形式Form1並添加以下XML架構的項目(XSD文件顯示在Solution Explorer):

<?xml version="1.0" encoding="utf-8"?> 
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.finetime.com" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.finetime.com"> 
    <xs:element name="Root"> 
    <xs:complexType> 
     <xs:sequence> 
     <xs:element name="Parent"> 
      <xs:complexType> 
      <xs:sequence> 
       <xs:element name="Child" type="xs:string" /> 
      </xs:sequence> 
      </xs:complexType> 
     </xs:element> 
     </xs:sequence> 
    </xs:complexType> 
    </xs:element> 
</xs:schema> 

Form1的代碼如下所示:

Imports <xmlns:ft="http://www.finetime.com"> 

Public Class Form1 
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 
     Dim xmlPath As String = IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.MyDocuments, "Test.xml") 
     Dim xmlDoc As XDocument = XDocument.Load(xmlPath) 
     Dim root As XElement = xmlDoc.<ft:Root>.First 
     Dim data As String = root.<ft:Parent>.<ft:Child>.Value 
     MessageBox.Show(data) 
    End Sub 
End Class 

當點擊按鈕時,項目編譯,運行並在MessageBox中顯示「數據」,但XML字完成未發生。

例如,當我鍵入Dim root As XElement = xmlDoc.<ft:時,我希望顯示XML元素名稱的選項來完成語句,但不顯示任何內容。我錯過了一步嗎?

+1

我沒有2015 installled,但可能你的問題涉及到[https://connect.microsoft.com/VisualStudio/feedback/details/ 1085407/intellisense-not-working-with-xml-to-schema](https://connect.microsoft.com/VisualStudio/feedback/details/1085407/intellisense-not-working-with-xml-to-schema) – TnTinMn

+0

@TnTinMn恐怕你說得對(雖然bug報告只是指由「XML到Schema」過程創建的模式)。感謝您指點我的錯誤報告,我已經提交了報告(希望這可能有助於引起對此問題的關注)。 – Blackwood

+0

@TnTinMn看來沒有人有任何其他解釋。你能發表一個答案,以便我可以接受它。 – Blackwood

回答

3

看起來好像在Roslyn重建(VS2015)下VB不包括XML Intellisense。這在MS Connect票證中有記錄:https://connect.microsoft.com/VisualStudio/feedback/details/1085407/intellisense-not-working-with-xml-to-schema

發佈由凱文[MSFT]在2015年1月14日在上午9時43分嗨,

感謝您的反饋意見。不幸的是,這是VB IDE經驗的一個角落,它還沒有被重建爲Roslyn項目的一部分。我們在我們的積壓項目上有一個工作項目,考慮在未來實施此項工作 。

- 凱文·皮爾希,比森的Visual Studio託管語言

相關問題