我们的 app.config 文件中有一个自定义部分与我们的 IoC 容器类相关。在编辑此部分的配置文件时如何获得智能感知,以及如何摆脱通知我缺少架构的编译器消息。
我在这里发现了这个问题:app.config configSections custom settings can not find schema information ,但我不明白它是否适用于我的问题,如果适用,如何在那里使用答案。
我也找到了这个页面How to get Intellisense for Web.config and App.config in Visual Studio .NET ,但它表示在运行应用程序之前删除 xmlns 属性。这真的是唯一/最好的方法吗?
这是一个简单文件的示例:
<?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>
里面节点,并在智能感知下拉列表中获取向我建议的注册,以及它的适当属性。
最佳答案
XML Intellisense 不会自动为自定义配置部分工作。
Visual Studio 可能会在编译时报告警告,提示未定义自定义配置部分的属性。这些警告可能会被忽略。
如果您希望 XML IntelliSense 支持自定义配置部分(或者如果您只是希望“未找到架构”警告消失),请在第一个
<xs:include schemaLocation="YOUR_DIRECTORY\namespace.assemblyname.xsd"/>
DotNetConfig.xsd 文件可以在 Visual Studio 8(或 9)安装目录的 Xml\Schemas 子目录中找到。
关于c# - 如何在自定义部分的 app.config 中获取智能感知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/378105/