views:

12082

answers:

3

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.

+1  A: 

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.

Franci Penov
Where is the Schema file?
StingyJack
+8  A: 

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 a 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.

+4  A: 

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 any more.

<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>
This works great!!! Thanks for the technique. Now I know how to make one for the remoting config.
StingyJack
I changed the sequence to all for the 3rd line so that the sections can appear in any order.
StingyJack