简体   繁体   中英

Not getting VS2013 Intellisense for custom config even with schema defined

I have custom config section which I can read correctly. Now I wanted Intellisense for it.

I have created my schema by first creating an XML with only my config section, and then got VS2013 to generate the Schema file for me. Named it CustomConfig.xsd and added to my project. I updated the schema based on @stakx's answer in this SO item , so it looks like this:

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

Then in my app.config I added the schema details to <customConfig> , like this:

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

Saved everything, then I tried to test it by editing <someElement> , but there is no Intellisense. What am I missing?

I can see that when I open my app.config and view the Property Window, the Schemas show my schema file as ticked. So I can only assume it is picking up the schema attribute from my app.config . Yet no Intellisense.

UPDATE

I just realised I do not get Intellisense at all on my app.config .

I opened my solution on VS2015, and it gives me Intellisense on my custom config.

Then I noticed on my VS2013, for some reason, does not use the DotNetConfig.xsd by default. This was not the case on VS2015. When I ticked it on VS2013 so it is used, Intellisense for my custom config started working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM