How do I make a schema for custom config sections? I tried making one, but when I used it, it said the only expected element was what I had in that schema, and complained about the standard web.config stuff, even though I was still using the normal DotNetConfig.xsd file too.
How to generate/create a schema xsd from an XML document? Step 1: click Open File button and select the xml file from the file system that you have access, or get the xml file from internet via URL, click By URL. Step 2: click the Generate XSD button, the generated schema will be displayed in an indented XML format.
An XML schema definition (XSD), is a framework document that defines the rules and constraints for XML documents. An XSD formally describes the elements in an XML document and can be used to validate the contents of the XML document to make sure that it adheres to the rules of the XSD.
This question I found isn't duplicate, but the solution will solve your problem:
How to fix Error: "Could not find schema information for the attribute/element" by creating schema
Schemas
value:My app.config file's properties window/gadget looks like this:
Here's an example I just got working (I'm toying around with Ninject and NLog). The elements and attributes under the nlog
section show up correctly in Intellisense, and I get squiggly lines if I violate the schema.
<?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>
My schema file is in my project root, right next to app.config, and called NLog.xsd
. I simply saved it from here:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With