如何为自定义配置部分创建架构?我尝试制作一个,但是当我使用它时,它表示唯一的预期元素是我在该模式中,并抱怨标准的web.config的东西,即使我仍然使用正常的DotNetConfig.xsd文件。
解决方法
我发现这个问题并不重要,但解决方案将会解决您的问题:
How to fix Error: “Could not find schema information for the attribute/element” by creating schema
诀窍是获取app.config编辑器的“属性”,并设置模式值:
>右键点击 – >属性在XML文件编辑器中的任何地方,或者只要点击F4即可
>在该对话框中,向模式文件添加本地或绝对引用
我的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>
我的架构文件位于我的项目根目录,紧邻app.config,并且名为NLog.xsd。我只是从这里保存:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。