我如何在智能感知为的app.config自定义栏目? [英] How do I get intellisense in app.config for a custom section?

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

问题描述

我们有一个自定义的部分与我们的Io​​C容器类我的app.config文件。我怎样才能编辑本节的配置文件时,以及摆脱编译器消息通知我丢失的架构中获得智能。

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.

我发现这个问题,在这里:的app.config configSections自定义设置找不到架构信息,但我不它是否适用于我的问题与否,以及如何,如果它确实使用了答案有了解。

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.

我也找到了这个网页< A HREF =htt​​p://www.radsoftware.com.au/articles/intellisensewebconfig.aspx>如何获得智能感知Web.config文件为和的App.config在Visual Studio .NET ,但它说,除去在XMLNS运行应用程序之前属性。这真的是唯一/最好的办法

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>



基本上我希望能够输入< R <内部; ServiceContainers方式> 节点,并得到注册建议我在智能感知下拉列表,以及为它的相应的属性。

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智能感知不会自动为自定义配置部分工作。

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

Visual Studio中可能会报告警告编译抱怨说,自定义配置节的属性没有定义。这些警告可能被忽略。

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

如果你想为一个自定义配置节XML IntelliSense支持(或者,如果你只是想警告消失'未找到模式),下面一行添加到您的DotNetConfig第一℃后,立即.xsd文件; XS:架构...>线(其通常在DotNetConfig.xsd文件中的第二行)。

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



DotNetConfig.xsd文件可以在Visual Studio中找到8(或9)在安装目录Xml\Schemas子目录。

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天全站免登陆