2015-09-24 37 views
0

我有自定義配置部分,可以正確讀取。現在我想要它的Intellisense。即使定義架構,也不能獲得VS2013智能感知套件

我已經創建了我的模式,首先創建一個XML,只有我的配置部分,然後讓VS2013爲我生成模式文件。將其命名爲CustomConfig.xsd並添加到我的項目中。我更新的基礎上this SO item @ stakx的回答模式,所以它看起來是這樣的:

<xs:schema id="customConfigSchema" 
      targetNamespace="http://tempuri.org/customConfig.xsd" 
      elementFormDefault="qualified" 
      xmlns="http://tempuri.org/customConfig.xsd" 
      xmlns:mstns="http://tempuri.org/customConfig.xsd" 
      xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xs:element name="customConfig"> 
    <xs:complexType> 
     <xs:sequence> 
     <xs:element name="someElement"> 
      <xs:complexType> 
      ... 
      </xs:complexType> 
     </xs:element> 
     ... 
     </xs:sequence> 
    </xs:complexType> 
    </xs:element> 
</xs:schema> 

然後在我的app.config我加入了架構細節<customConfig>,像這樣:

<configuration> 
    <configSections> 
    ... 
    <section name="customConfig" type="..." /> 
    </configSections> 
    ... 
    <customConfig xmlns="http://tempuri.org/customConfig.xsd" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema" 
       xsi:noNamespaceSchemaLocation="customConfig.xsd"> 
    <someElement ... /> 
    </customConfig> 
</configuration> 

保存的一切,然後我試圖通過編輯<someElement>來測試它,但沒有智能感知。我錯過了什麼?

我可以看到,當我打開我的app.config並查看屬性窗口時,架構將我的架構文件顯示爲打勾。所以我只能假設它正從我的app.config中獲取架構屬性。但沒有智能感知。

UPDATE

我才意識到我沒有得到智能感知都在我的app.config

回答

0

我在VS2015上打開了我的解決方案,它給我自定義配置上的Intellisense。

然後我注意到我的VS2013,出於某種原因,默認情況下不使用DotNetConfig.xsd。 VS2015的情況並非如此。當我在VS2013上勾選它以便使用它時,我的自定義配置的Intellisense開始工作。