Max*_*ing 20 .net configuration xsd
如何为自定义配置节创建架构?我尝试制作一个,但是当我使用它时,它说唯一预期的元素是我在该模式中所拥有的,并抱怨标准的web.config内容,即使我仍然使用正常的DotNetConfig.xsd文件.
Mer*_*ham 37
我发现这个问题不重复,但解决方案将解决您的问题:
Schemas值:我的app.config文件的属性窗口/小工具如下所示:

这是我刚刚开始工作的一个例子(我正在使用Ninject和NLog).该部分下的元素和属性nlog在Intellisense中正确显示,如果我违反了模式,我会得到波浪线.
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
</configSections>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="eventLog" xsi:type="EventLog" log="Application"
category="TestService" />
<target name="file" xsi:type="File"
layout="${longdate}|${stacktrace}|${message}"
fileName="${logger}.txt" />
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="eventLog" />
<logger name="*" minlevel="Debug" writeTo="file"/>
</rules>
</nlog>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我的架构文件位于我的项目根目录中,紧挨着app.config,并被调用NLog.xsd.我只是从这里保存它: