如何在app.config中获取自定义部分的智能感知? [英] How do I get intellisense in app.config for a custom section?

查看:259
本文介绍了如何在app.config中获取自定义部分的智能感知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的app.config文件中有一个自定义部分,与我们的Io​​C容器类相关。如何在编辑此部分的配置文件时获取intellisense,以及摆脱编译器消息通知我缺少的模式。



我在这里找到了这个问题: app.config configSections自定义设置找不到模式信息 a>,但我不明白如果它适用于我的问题,如果它是如何使用的答案。如果它是。



我也发现这个页面< a href =http://www.radsoftware.com.au/articles/intellisensewebconfig.aspx =nofollow noreferrer>如何在Visual Studio .NET中获取Intellisense for Web.config和App.config ,但它说在运行应用程序之前删除xmlns属性。



这是一个简单文件的例子:

 <?xml version =1.0encoding =utf-8?> 
< configuration>
< configSections>
< section name =ServiceContainers
type =LVK.IoC.RegistrationsSectionHandler,LVK/>
< / configSections>
< ServiceContainers>
< Registration type =DatabaseConnectionclass =DatabaseConnection>
< Parameter name =connectionStringtype =System.String
value =TYPE = MSSQL2000; SERVER = localhost; DATABASE = db/>
< / Registration>
< / ServiceContainers>
< / config>

基本上我想能够输入< R < ServiceContainers> 节点内,并在Intellisense下拉列表中获取注册建议给我,以及它的适当属性。

$ XML Intellisense将不会自动工作在自定义配置部分。



Visual Studio可能会报告有关编译的警告,指出未定义自定义配置节的属性。这些警告可能会被忽略。



如果您想要为自定义配置部分提供XML IntelliSense支持(或者如果您只是希望模式未找到警告消失),请将以下行添加到您的DotNetConfig .xsd文件紧跟在第一个< xs:schema ...>行(通常是DotNetConfig.xsd文件中的第二行)。

 < xs:include schemaLocation =YOUR_DIRECTORY\\\
amespace.assemblyname.xsd/>

DotNetConfig.xsd文件可以在Visual Studio 8 Xml \Schemas子目录。


We have a custom section in my app.config file related to our IoC container class. How can I get intellisense when editing the config file for this section, as well as getting rid of the compiler messages informing me of the missing schema.

I found this question here: app.config configSections custom settings can not find schema information, but I don't understand if it applies to my problem or not, and how to use the answer there if it does.

I also found this page How to get Intellisense for Web.config and App.config in Visual Studio .NET, but it says to remove the xmlns attribute before running the application. Is that really the only/best way?

Here is an example of a simple file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="ServiceContainers"
        type="LVK.IoC.RegistrationsSectionHandler, LVK"/>
  </configSections>
  <ServiceContainers>
    <Registration type="DatabaseConnection" class="DatabaseConnection">
      <Parameter name="connectionString" type="System.String"
          value="TYPE=MSSQL2000;SERVER=localhost;DATABASE=db"/>
    </Registration>
  </ServiceContainers>
</configuration>

Basically I would like to be able to type <R inside the <ServiceContainers> node, and get Registration suggested to me in the intellisense dropdown, as well as the appropriate attributes for it.

解决方案

XML Intellisense will not automatically work for a custom configuration section.

Visual Studio may report warnings on compilation complaining that the attributes of the custom configuration section are not defined. These warnings may be ignored.

If you want XML IntelliSense support for a custom configuration section (or if you just want the 'schema not found' warnings to disappear), add the following line to your DotNetConfig.xsd file immediately after the first <xs:schema ...> line (which is typically the second line in the DotNetConfig.xsd file).

<xs:include schemaLocation="YOUR_DIRECTORY\namespace.assemblyname.xsd"/>

The DotNetConfig.xsd file can be found in your Visual Studio 8 (or 9) installation directory in the Xml\Schemas subdirectory.

这篇关于如何在app.config中获取自定义部分的智能感知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆