How to resolve "Could not find schema information for the element/attribute <xxx>"?

150,941

Solution 1

I configured the app.config with the tool for EntLib configuration and set up my LoggingConfiguration block. Then I copied this into the DotNetConfig.xsd. Of course, it does not cover all attributes, only the ones I added but it does not display those annoying info messages anymore.

<xs:element name="loggingConfiguration">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="listeners">
        <xs:complexType>
          <xs:sequence>
            <xs:element maxOccurs="unbounded" name="add">
              <xs:complexType>
                <xs:attribute name="fileName" type="xs:string" use="required" />
                <xs:attribute name="footer" type="xs:string" use="required" />
                <xs:attribute name="formatter" type="xs:string" use="required" />
                <xs:attribute name="header" type="xs:string" use="required" />
                <xs:attribute name="rollFileExistsBehavior" type="xs:string" use="required" />
                <xs:attribute name="rollInterval" type="xs:string" use="required" />
                <xs:attribute name="rollSizeKB" type="xs:unsignedByte" use="required" />
                <xs:attribute name="timeStampPattern" type="xs:string" use="required" />
                <xs:attribute name="listenerDataType" type="xs:string" use="required" />
                <xs:attribute name="traceOutputOptions" type="xs:string" use="required" />
                <xs:attribute name="filter" type="xs:string" use="required" />
                <xs:attribute name="type" type="xs:string" use="required" />
                <xs:attribute name="name" type="xs:string" use="required" />
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="formatters">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="add">
              <xs:complexType>
                <xs:attribute name="template" type="xs:string" use="required" />
                <xs:attribute name="type" type="xs:string" use="required" />
                <xs:attribute name="name" type="xs:string" use="required" />
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="logFilters">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="add">
              <xs:complexType>
                <xs:attribute name="enabled" type="xs:boolean" use="required" />
                <xs:attribute name="type" type="xs:string" use="required" />
                <xs:attribute name="name" type="xs:string" use="required" />
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="categorySources">
        <xs:complexType>
          <xs:sequence>
            <xs:element maxOccurs="unbounded" name="add">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="listeners">
                    <xs:complexType>
                      <xs:sequence>
                        <xs:element name="add">
                          <xs:complexType>
                            <xs:attribute name="name" type="xs:string" use="required" />
                          </xs:complexType>
                        </xs:element>
                      </xs:sequence>
                    </xs:complexType>
                  </xs:element>
                </xs:sequence>
                <xs:attribute name="switchValue" type="xs:string" use="required" />
                <xs:attribute name="name" type="xs:string" use="required" />
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="specialSources">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="allEvents">
              <xs:complexType>
                <xs:attribute name="switchValue" type="xs:string" use="required" />
                <xs:attribute name="name" type="xs:string" use="required" />
              </xs:complexType>
            </xs:element>
            <xs:element name="notProcessed">
              <xs:complexType>
                <xs:attribute name="switchValue" type="xs:string" use="required" />
                <xs:attribute name="name" type="xs:string" use="required" />
              </xs:complexType>
            </xs:element>
            <xs:element name="errors">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="listeners">
                    <xs:complexType>
                      <xs:sequence>
                        <xs:element name="add">
                          <xs:complexType>
                            <xs:attribute name="name" type="xs:string" use="required" />
                          </xs:complexType>
                        </xs:element>
                      </xs:sequence>
                    </xs:complexType>
                  </xs:element>
                </xs:sequence>
                <xs:attribute name="switchValue" type="xs:string" use="required" />
                <xs:attribute name="name" type="xs:string" use="required" />
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="name" type="xs:string" use="required" />
    <xs:attribute name="tracingEnabled" type="xs:boolean" use="required" />
    <xs:attribute name="defaultCategory" type="xs:string" use="required" />
    <xs:attribute name="logWarningsWhenNoCategoriesMatch" type="xs:boolean" use="required" />
  </xs:complexType>
</xs:element>

Solution 2

I've created a new scheme based on my current app.config to get the messages to disappear. I just used the button in Visual Studio that says "Create Schema" and an xsd schema was created for me.

Save the schema in an apropriate place and see the "Properties" tab of the app.config file where there is a property named Schemas. If you click the change button there you can select to use both the original dotnetconfig schema and your own newly created one.

Solution 3

An XSD is included with EntLib 5, and is installed in the Visual Studio schema directory. In my case, it could be found at:

"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Xml\Schemas\EnterpriseLibrary.Configuration.xsd"

CONTEXT

  • Visual Studio 2010
  • Enterprise Library 5

STEPS TO REMOVE THE WARNINGS

  1. open app.config in your Visual Studio project
  2. right click in the XML Document editor, select "Properties"
  3. add the fully qualified path to the "EnterpriseLibrary.Configuration.xsd"

ASIDE

It is worth repeating that these "Error List" "Messages" ("Could not find schema information for the element") are only visible when you open the app.config file. If you "Close All Documents" and compile... no messages will be reported.

Solution 4

Have you tried copying the schema file to the XML Schema Caching folder for VS? You can find the location of that folder by looking at VS Tools/Options/Test Editor/XML/Miscellaneous. Unfortunately, i don't know where's the schema file for the MS Enterprise Library 4.0.

Update: After installing MS Enterprise Library, it seems there's no .xsd file. However, there's a tool for editing the configuration - EntLibConfig.exe, which you can use to edit the configuration files. Also, if you add the proper config sections to your config file, VS should be able to parse the config file properly. (EntLibConfig will add these for you, or you can add them yourself). Here's an example for the loggingConfiguration section:

<configSections>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</configSections>

You also need to add a reference to the appropriate assembly in your project.

Solution 5

What fixed the "Could not find schema information for the element ..." for me was

  • Opening my app.config.
  • Right-clicking in the editor window and selecting Properties.
  • In the properties box, there is a row called Schemas, I clicked that row and selected the browse ... box that appears in the row.
  • I simply checked the use box for all the rows that had my project somewhere in them, and also for the current version of .Net I was using. For instance: DotNetConfig30.xsd.

After that everything went to working fine.

How those schema rows with my project got unchecked I'm not sure, but when I made sure they were checked, I was back in business.

Share:
150,941

Related videos on Youtube

StingyJack
Author by

StingyJack

Don't make people into victims of policy. People come looking for help. Don't deny them all assistance because you find the question does not perfectly match with the rules. Any code I offer as an answer or comment comes also with the WTFPL or Free Public license, regardless of whatever changes are made to the site TOS. Do whatever you like with it, no attribution ever required.

Updated on September 18, 2020

Comments

  • StingyJack
    StingyJack over 3 years

    In visual studio, I have an asp.net 3.5 project that is using MS Enterprise Library 4.0 application blocks.

    When I have my web config file open, my Error list fills up with 99 messages with things like

    Could not find schema information for the element 'dataConfiguration'.  
    Could not find schema information for the attribute 'defaultDatabase'.  
    Could not find schema information for the element 'loggingConfiguration'.   
    Could not find schema information for the attribute 'tracingEnabled'.   
    Could not find schema information for the attribute 'defaultCategory'.  
    

    If I close the Web.config file they go away (but they come back as soon as I need to open the file again).

    After doing some looking, I found that this is becauase there is an XSD or schema file missing that Visual Studio needs in order to properly 'understand' the schema that is in the web.config file and provide intellisense for it.

    Does anyone know how to either supply VS with the appropriate schema information, or to turn off these messages?

    @Franci - Thanks for the info, I have tried that tool as well as the MMC snap in (they tend to blow up the formatting in the Web.config) but they still do not resolve the irritating warnings I receive. Thanks for trying.

    • Franci Penov
      Franci Penov over 15 years
      Hey, sorry I couldn't help you. If you want me to delete my answer so your question shows as unanswered, leave a comment on the answer, so I can see it next time I log.
    • Saad Farooq
      Saad Farooq over 7 years
      I solved it by just restarting my visual studio.
  • StingyJack
    StingyJack over 15 years
    This works great!!! Thanks for the technique. Now I know how to make one for the remoting config.
  • StingyJack
    StingyJack over 15 years
    I changed the sequence to all for the 3rd line so that the sections can appear in any order.
  • Brian McCarthy
    Brian McCarthy about 13 years
    @user57433 - Where is the EntLib configuration tool and DotNetConfig.xsd file located?
  • yzorg
    yzorg almost 13 years
    In the XSD you might have to sprinkle in minOccurs="0" so you won't get validation warnings when you move/remove sections, like your <applicationSettings><Company.MyApplication.Settings.Propert‌​ies>
  • Roman Pokrovskij
    Roman Pokrovskij over 12 years
    Just want to add that this "Schema" property you can access only editing the xml file (app.config) and not from browsing Solution Explorer
  • George
    George over 12 years
    I created a xsd schema as you described above. I did help me to get rid of the "Could not find schema information for..." - messages, however now I'm getting the warning "The global element 'configuration' has already been declared." in app.xsd. Does anyone know how to solve this?
  • DaveN59
    DaveN59 about 12 years
    Super simple solution. It's even simpler if you click the ellipsis button to the right of the path variable once you open properties -- that brings up a dialog box where you can simply click on the XML schema you want included...
  • DaveN59
    DaveN59 about 12 years
    Way too much work. You can just open properties for app.config, click on the Path variable, then click on the ellipsis button. That brings up a dialog box where you can select whatever schema you want to include.
  • Contango
    Contango about 12 years
    In Visual Studio 2010, to find the button "Create Schema", first open "app.config" to enable XML tools, then mouse over the buttons on the toolbar. If you still can't find it, right click on the toolbar, and make sure "XML Editor" is selected. You can also use the menu "XML..Create Schema".
  • Giles Roberts
    Giles Roberts about 11 years
    Does this apply to the web.config of an ASP.NET MVC project too? I've added the created xsd file to the schemas for my web.config but the errors haven't gone away.