【问题标题】:Not getting VS2013 Intellisense for custom config even with schema defined即使定义了架构,也没有为自定义配置获取 VS2013 Intellisense
【发布时间】:2015-12-21 13:39:17
【问题描述】:

我有自定义配置部分,我可以正确阅读。现在我想要 Intellisense。

我创建了我的架构,首先创建一个只有我的配置部分的 XML,然后让 VS2013 为我生成架构文件。将其命名为 CustomConfig.xsd 并添加到我的项目中。我根据@stakx 在this SO item 中的回答更新了架构,所以它看起来像这样:

<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 中,我将架构详细信息添加到&lt;customConfig&gt;,如下所示:

<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>

保存所有内容,然后我尝试通过编辑&lt;someElement&gt; 对其进行测试,但没有智能感知。我错过了什么?

我可以看到,当我打开我的 app.config 并查看属性窗口时,架构将我的架构文件显示为勾选。所以我只能假设它从我的app.config 中获取模式属性。但是没有智能感知。

更新

我刚刚意识到我的 app.config 上根本没有 Intellisense。

【问题讨论】:

    标签: c# intellisense custom-configuration


    【解决方案1】:

    我在 VS2015 上打开了我的解决方案,它在我的自定义配置上提供了 Intellisense。

    然后我注意到在我的 VS2013 上,出于某种原因,默认情况下不使用 DotNetConfig.xsd。在 VS2015 上并非如此。当我在 VS2013 上勾选它以便使用它时,我的自定义配置的 Intellisense 开始工作。

    【讨论】:

      猜你喜欢
      • 2020-03-25
      • 1970-01-01
      • 1970-01-01
      • 2020-02-25
      • 1970-01-01
      • 2023-02-07
      • 2014-01-10
      • 2021-12-26
      • 1970-01-01
      相关资源
      最近更新 更多