<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Dave Kehring - Configuration</title>
    <link>http://blog.whconsult.com/</link>
    <description>partial class DaveKehring : IProgrammer { } </description>
    <language>en-us</language>
    <copyright>Dave Kehring</copyright>
    <lastBuildDate>Tue, 07 Apr 2009 22:03:41 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.1.8102.813</generator>
    <managingEditor>dave.kehring@whconsult.com</managingEditor>
    <webMaster>dave.kehring@whconsult.com</webMaster>
    <item>
      <trackback:ping>http://blog.whconsult.com/Trackback.aspx?guid=0b1b7f79-3c6f-4fa5-be2d-5bf8d924c3f1</trackback:ping>
      <pingback:server>http://blog.whconsult.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.whconsult.com/PermaLink,guid,0b1b7f79-3c6f-4fa5-be2d-5bf8d924c3f1.aspx</pingback:target>
      <dc:creator>Dave Kehring</dc:creator>
      <wfw:comment>http://blog.whconsult.com/CommentView,guid,0b1b7f79-3c6f-4fa5-be2d-5bf8d924c3f1.aspx</wfw:comment>
      <wfw:commentRss>http://blog.whconsult.com/SyndicationService.asmx/GetEntryCommentsRss?guid=0b1b7f79-3c6f-4fa5-be2d-5bf8d924c3f1</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Don't you just love those days when you come to work full of energy and ideas, ready
to have a productive day only to be stumped by a seemingly simple problem that ends
up wasting the entire day? Today was one of those days. My only consolation is that
this blog post reports the solution, hopefully saving some other poor soul their time
and their sanity.
</p>
        <p>
The need was simple. Write out connection strings to the app.config file of an application
and encrypt them. Sound easy? Sure. There are lots of examples out there about how
to do this, but there's a problem no one seems to mention. You can't just update a
config file at runtime and expect those changes to stick. I ran into that problem
the other day and solved it <a href="http://blog.whconsult.com/2009/04/01/ConfigurationFileChangesWontPersist.aspx">here</a>.
But there's a more sinister problem. Let me explain.
</p>
        <p>
First, here's what I'm doing:
</p>
        <p>
          <img src="http://blog.whconsult.com/content/binary/4-7-2009 5-41-37 PM.png" border="0" />
        </p>
        <p>
I have an array of connection strings (as strings) from an external service that I
want to add to the app.config file of the current application. I write them out to
the &lt;connectionStrings&gt; section and then save the file, taking care to make
sure I tell the System.Configuration.ConfigurationManager to refresh the section,
meaning it should reload the section from disk the next time it's accessed.
</p>
        <p>
When this happens further along in the program on this line ...
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ConnectionStringSettings
dbConn <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> System.Configuration.ConfigurationManager.ConnectionStrings[DefaultDatabaseKey]; </span>
        </pre>
        <p>
... I get this error message:
</p>
        <p>
          <em>Unrecognized attribute 'configProtectionProvider'.</em>
        </p>
        <p>
I did the usual searches and came up with no solutions. Some folks suggested loading
two AppDomains, restarting the app, etc. I can't believe you'd have to restart an
app just to pick up configuration changes! After all, I can to this now. The problem
comes when I try to encrypt the section.
</p>
        <p>
          <img src="http://blog.whconsult.com/content/binary/4-7-2009 5-41-37 PM1.png" border="0" />
        </p>
        <p>
When you successfully encrpyt a section, a new attribute "configProtectionProvider"
is added to the &lt;connectionStrings&gt; element. It appears that when ConfigurationManager
tries to reload this section, it can't digest this new attribute.
</p>
        <p>
Okay, let's just get to the solution before I waste even more of my day...
</p>
        <p>
The answer turned out to be simple. Instead of telling ConfigurationManager to refresh
the "connectionStrings" section, have it refresh the next level up which would be
the &lt;configuration&gt; section itself:
</p>
        <p>
          <img src="http://blog.whconsult.com/content/binary/4-7-2009 6-01-44 PM1.png" border="0" />
        </p>
        <p>
Oh happy day.
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://blog.whconsult.com/aggbug.ashx?id=0b1b7f79-3c6f-4fa5-be2d-5bf8d924c3f1" />
      </body>
      <title>Unrecognized attribute configProtectionProvider</title>
      <guid isPermaLink="false">http://blog.whconsult.com/PermaLink,guid,0b1b7f79-3c6f-4fa5-be2d-5bf8d924c3f1.aspx</guid>
      <link>http://blog.whconsult.com/2009/04/07/UnrecognizedAttributeConfigProtectionProvider.aspx</link>
      <pubDate>Tue, 07 Apr 2009 22:03:41 GMT</pubDate>
      <description>&lt;p&gt;
Don't you just love those days when you come to work full of energy and ideas, ready
to have a productive day only to be stumped by a seemingly simple problem that ends
up wasting the entire day? Today was one of those days. My only consolation is that
this blog post reports the solution, hopefully saving some other poor soul their time
and their sanity.
&lt;/p&gt;
&lt;p&gt;
The need was simple. Write out connection strings to the app.config file of an application
and encrypt them. Sound easy? Sure. There are lots of examples out there about how
to do this, but there's a problem no one seems to mention. You can't just update a
config file at runtime and expect those changes to stick. I ran into that problem
the other day and solved it &lt;a href="http://blog.whconsult.com/2009/04/01/ConfigurationFileChangesWontPersist.aspx"&gt;here&lt;/a&gt;.
But there's a more sinister problem. Let me explain.
&lt;/p&gt;
&lt;p&gt;
First, here's what I'm doing:
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://blog.whconsult.com/content/binary/4-7-2009 5-41-37 PM.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
I have an array of connection strings (as strings) from an external service that I
want to add to the app.config file of the current application. I write them out to
the &amp;lt;connectionStrings&amp;gt; section and then save the file, taking care to make
sure I tell the System.Configuration.ConfigurationManager to refresh the section,
meaning it should reload the section from disk the next time it's accessed.
&lt;/p&gt;
&lt;p&gt;
When this happens further along in the program on this line ...
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ConnectionStringSettings
dbConn &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; System.Configuration.ConfigurationManager.ConnectionStrings[DefaultDatabaseKey]; &lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
... I get this error message:
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;Unrecognized attribute 'configProtectionProvider'.&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
I did the usual searches and came up with no solutions. Some folks suggested loading
two AppDomains, restarting the app, etc. I can't believe you'd have to restart an
app just to pick up configuration changes! After all, I can to this now. The problem
comes when I try to encrypt the section.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://blog.whconsult.com/content/binary/4-7-2009 5-41-37 PM1.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
When you successfully encrpyt a section, a new attribute "configProtectionProvider"
is added to the &amp;lt;connectionStrings&amp;gt; element. It appears that when ConfigurationManager
tries to reload this section, it can't digest this new attribute.
&lt;/p&gt;
&lt;p&gt;
Okay, let's just get to the solution before I waste even more of my day...
&lt;/p&gt;
&lt;p&gt;
The answer turned out to be simple. Instead of telling ConfigurationManager to refresh
the "connectionStrings" section, have it refresh the next level up which would be
the &amp;lt;configuration&amp;gt; section itself:
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://blog.whconsult.com/content/binary/4-7-2009 6-01-44 PM1.png" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Oh happy day.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.whconsult.com/aggbug.ashx?id=0b1b7f79-3c6f-4fa5-be2d-5bf8d924c3f1" /&gt;</description>
      <comments>http://blog.whconsult.com/CommentView,guid,0b1b7f79-3c6f-4fa5-be2d-5bf8d924c3f1.aspx</comments>
      <category>Configuration</category>
    </item>
    <item>
      <trackback:ping>http://blog.whconsult.com/Trackback.aspx?guid=a6c00bb4-493c-43cb-bcb4-71b032d76e04</trackback:ping>
      <pingback:server>http://blog.whconsult.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.whconsult.com/PermaLink,guid,a6c00bb4-493c-43cb-bcb4-71b032d76e04.aspx</pingback:target>
      <dc:creator>Dave Kehring</dc:creator>
      <wfw:comment>http://blog.whconsult.com/CommentView,guid,a6c00bb4-493c-43cb-bcb4-71b032d76e04.aspx</wfw:comment>
      <wfw:commentRss>http://blog.whconsult.com/SyndicationService.asmx/GetEntryCommentsRss?guid=a6c00bb4-493c-43cb-bcb4-71b032d76e04</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I was running into a problem when trying to modify the app.config file for an application
at runtime. Specifically, I was adding connection strings to the &lt;connectionStrings&gt;
section but further along in my code the changes were not visible. However, the configuration
file was changed! How could this be? After much head scratching and research, I find
the problem.
</p>
        <p>
To change the app.config file I was opening the config file like this:
</p>
        <font size="2">
          <p>
     System.Configuration.
</p>
        </font>
        <font color="#2b91af" size="2">
          <font color="#2b91af" size="2">ConfigurationManager</font>
        </font>
        <font size="2">.OpenExeConfiguration(</font>
        <font color="#2b91af" size="2">
          <font color="#2b91af" size="2">ConfigurationUserLevel</font>
        </font>
        <font size="2">.None);
</font>
        <p>
I then add or update individual connection strings as need (that code's not important).
Finally, I save the changes:
</p>
        <font size="2">
          <p>
     config.Save(System.Configuration.
</p>
        </font>
        <font color="#2b91af" size="2">
          <font color="#2b91af" size="2">ConfigurationSaveMode</font>
        </font>
        <font size="2">.Modified);</font>
        <p>
          <font size="2">Further on in the code I then attempt to access the connection strings,
but instead I use the ConfigurationManager class like this:</font>
        </p>
        <font size="2">
          <font size="2">
            <font color="#2b91af" size="2">
              <font color="#2b91af" size="2">
                <p>
     ConnectionStringSettings
</p>
              </font>
            </font>
            <font color="#000000" size="2"> dbConn = System.Configuration.</font>
            <font color="#2b91af" size="2">
              <font color="#2b91af" size="2">ConfigurationManager</font>
            </font>
            <font size="2">
              <font color="#000000">.ConnectionStrings[DefaultDatabaseKey];</font>
            </font>
            <p>
The problem is that the ConfigurationManager - which is a static class - already
has a stored copy of the configuration file in its internals. The answer is to
call RefreshSection("...") after saving changes to the config file:
</p>
            <font size="2">
              <p>
   config.Save(System.Configuration.
</p>
            </font>
            <font color="#2b91af" size="2">
              <font color="#2b91af" size="2">ConfigurationSaveMode</font>
            </font>
            <font size="2">.Modified);<br />
   System.Configuration.</font>
            <font color="#2b91af" size="2">
              <font color="#2b91af" size="2">ConfigurationManager</font>
            </font>
            <font size="2">.RefreshSection(</font>
            <font color="#a31515" size="2">
              <font color="#a31515" size="2">"connectionStrings"</font>
            </font>
            <font size="2">);
</font>
            <p>
              <font size="2">
                <font color="#000000">
                </font> 
</font>
            </p>
          </font>
        </font>
        <img width="0" height="0" src="http://blog.whconsult.com/aggbug.ashx?id=a6c00bb4-493c-43cb-bcb4-71b032d76e04" />
      </body>
      <title>Configuration File Changes Won't Persist</title>
      <guid isPermaLink="false">http://blog.whconsult.com/PermaLink,guid,a6c00bb4-493c-43cb-bcb4-71b032d76e04.aspx</guid>
      <link>http://blog.whconsult.com/2009/04/01/ConfigurationFileChangesWontPersist.aspx</link>
      <pubDate>Wed, 01 Apr 2009 16:21:45 GMT</pubDate>
      <description>&lt;p&gt;
I was running into a problem when trying to modify the app.config file for an application
at runtime. Specifically, I was adding connection strings to the &amp;lt;connectionStrings&amp;gt;
section but further along in my code the changes were not visible. However, the configuration
file was changed! How could this be? After much head scratching and research, I find
the problem.
&lt;/p&gt;
&lt;p&gt;
To change the app.config file I was opening the config file like this:
&lt;/p&gt;
&lt;font size=2&gt; 
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Configuration.
&lt;/font&gt;&lt;font color=#2b91af size=2&gt;&lt;font color=#2b91af size=2&gt;ConfigurationManager&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;.OpenExeConfiguration(&lt;/font&gt;&lt;font color=#2b91af size=2&gt;&lt;font color=#2b91af size=2&gt;ConfigurationUserLevel&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;.None);&gt;
&lt;/font&gt; 
&lt;p&gt;
I then add or update individual connection strings as need (that code's not important).
Finally, I save the changes:
&lt;/p&gt;
&lt;font size=2&gt; 
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; config.Save(System.Configuration.
&lt;/font&gt;&lt;font color=#2b91af size=2&gt;&lt;font color=#2b91af size=2&gt;ConfigurationSaveMode&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;.Modified);&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font size=2&gt;Further on in the code I then attempt to access the connection strings,
but instead I use the ConfigurationManager class like this:&lt;/font&gt;
&lt;/p&gt;
&lt;font size=2&gt;&lt;font size=2&gt;&lt;font color=#2b91af size=2&gt;&lt;font color=#2b91af size=2&gt; 
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ConnectionStringSettings
&lt;/font&gt;&lt;/font&gt;&lt;font color=#000000 size=2&gt; dbConn = System.Configuration.&lt;/font&gt;&lt;font color=#2b91af size=2&gt;&lt;font color=#2b91af size=2&gt;ConfigurationManager&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font color=#000000&gt;.ConnectionStrings[DefaultDatabaseKey];&lt;/font&gt;&lt;/font&gt;&gt;
&lt;p&gt;
The problem is that the ConfigurationManager - which is a static class -&amp;nbsp;already
has a stored&amp;nbsp;copy of the configuration file in its internals. The answer is to
call RefreshSection("...") after saving changes to the config file:
&lt;/p&gt;
&lt;font size=2&gt; 
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;config.Save(System.Configuration.
&lt;/font&gt;&lt;font color=#2b91af size=2&gt;&lt;font color=#2b91af size=2&gt;ConfigurationSaveMode&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;.Modified);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;System.Configuration.&lt;/font&gt;&lt;font color=#2b91af size=2&gt;&lt;font color=#2b91af size=2&gt;ConfigurationManager&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;.RefreshSection(&lt;/font&gt;&lt;font color=#a31515 size=2&gt;&lt;font color=#a31515 size=2&gt;"connectionStrings"&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;);&gt;
&lt;/font&gt; 
&lt;p&gt;
&lt;font size=2&gt;&lt;font color=#000000&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;/font&gt;&lt;/font&gt;&gt;&lt;img width="0" height="0" src="http://blog.whconsult.com/aggbug.ashx?id=a6c00bb4-493c-43cb-bcb4-71b032d76e04" /&gt;</description>
      <comments>http://blog.whconsult.com/CommentView,guid,a6c00bb4-493c-43cb-bcb4-71b032d76e04.aspx</comments>
      <category>Configuration</category>
    </item>
    <item>
      <trackback:ping>http://blog.whconsult.com/Trackback.aspx?guid=1978f9ec-2e78-4d4d-af60-6507d3a91698</trackback:ping>
      <pingback:server>http://blog.whconsult.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.whconsult.com/PermaLink,guid,1978f9ec-2e78-4d4d-af60-6507d3a91698.aspx</pingback:target>
      <dc:creator>Dave Kehring</dc:creator>
      <wfw:comment>http://blog.whconsult.com/CommentView,guid,1978f9ec-2e78-4d4d-af60-6507d3a91698.aspx</wfw:comment>
      <wfw:commentRss>http://blog.whconsult.com/SyndicationService.asmx/GetEntryCommentsRss?guid=1978f9ec-2e78-4d4d-af60-6507d3a91698</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Intellisense is wonderful. It's so useful it's actually scary because it doesn't force
you to remember a lot class names, enum values, etc. This is good for productivity
but bad when you need to recall something without the Visual Studio IDE!
</p>
        <p>
In any case, I like to get Intellisense whenever I can. One area that I kept putting
off was adding Intellisense for custom configuration sections I create. I dislike
loads of &lt;add&gt; tags in the &lt;appSettings&gt; section because it becomes hard
to navigate. I prefer to create custom config sections. However, I don't get the benefit
- out of the box - of Intellisense and schema validation. To get this, you need to
create your own XSD file to support your custom config sections.
</p>
        <p>
XSDs for config sections are not hard to write. In fact, its best to just take a look
at the XSD file for the .NET config file which can be found in your Visual Studio
installation folder. For example, on my machine for VS 2008, I navigate to:
</p>
        <p>
C:\Program Files\Microsoft Visual Studio 9.0\Xml\Schemas
</p>
        <p>
Here you'll find loads of XSD files for all sorts of things. The most important one
however is called DotNetConfig.xsd. This contains the schema definitions for the base
.NET config file. There are also supplimental files for .NET 2.0 and 3.0 config sections
in DotNetConfig20.xsd and DotNetConfig30.xsd respectively.
</p>
        <p>
Here's a simple example of a config section:
</p>
        <font color="#0000ff" size="3">
          <font color="#0000ff" size="3">
            <p>
              <font size="2">&lt;</font>
            </p>
          </font>
        </font>
        <font color="#a31515">
          <font color="#a31515">fileRepositories</font>
        </font>
        <font color="#0000ff">
          <font color="#0000ff">&gt;<br />
    </font>
        </font>
        <font color="#0000ff">
          <font color="#0000ff">&lt;</font>
        </font>
        <font color="#a31515">
          <font color="#a31515">fileRepository</font>
        </font>
        <font color="#0000ff">
          <font color="#0000ff">
          </font>
        </font>
        <font color="#ff0000">
          <font color="#ff0000">id</font>
        </font>
        <font color="#0000ff">
          <font color="#0000ff">=</font>
        </font>
        <font color="#000000">"</font>
        <font color="#0000ff">
          <font color="#0000ff">MainLib</font>
        </font>
        <font color="#000000">"</font>
        <font color="#0000ff">
          <font color="#0000ff">
          </font>
        </font>
        <font color="#ff0000">
          <font color="#ff0000">isDefault</font>
        </font>
        <font color="#0000ff">
          <font color="#0000ff">=</font>
        </font>
        <font color="#000000">"</font>
        <font color="#0000ff">
          <font color="#0000ff">true</font>
        </font>
        <font color="#000000">"</font>
        <font color="#0000ff">
          <font color="#0000ff">
          </font>
        </font>
        <font color="#ff0000">
          <font color="#ff0000">connectionString</font>
        </font>
        <font color="#0000ff">
          <font color="#0000ff">=</font>
        </font>
        <font color="#000000">"</font>
        <font color="#0000ff">
          <font color="#0000ff">\\JUPITER\MainLib</font>
        </font>
        <font color="#000000">"</font>
        <font color="#0000ff">
          <font color="#0000ff"> /&gt;<br /></font>
        </font>
        <font color="#0000ff">
          <font color="#0000ff">&lt;/</font>
        </font>
        <font color="#a31515">
          <font color="#a31515">fileRepositories</font>
        </font>
        <font color="#0000ff">
          <font color="#0000ff">&gt;</font>
        </font>
        <p>
          <font color="#0000ff" size="3">
            <font color="#0000ff" size="3">
              <font color="#000000" size="2">The
xsd schema (MyConfig.xsd) for this config section is:</font>
            </font>
          </font>
        </p>
        <font color="#0000ff" size="3">
          <font color="#0000ff" size="3">
            <font color="#000000" size="2">
              <font color="#0000ff" size="3">
                <font color="#0000ff" size="3">
                  <p>
                    <font size="2">&lt;?</font>
                  </p>
                </font>
              </font>
              <font color="#a31515">
                <font color="#a31515">xml</font>
              </font>
              <font color="#0000ff">
                <font color="#0000ff">
                </font>
              </font>
              <font color="#ff0000">
                <font color="#ff0000">version</font>
              </font>
              <font color="#0000ff">
                <font color="#0000ff">=</font>
              </font>"<font color="#0000ff"><font color="#0000ff">1.0</font></font>"<font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">encoding</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">us-ascii</font></font>"<font color="#0000ff"><font color="#0000ff">?&gt;<br />
   </font></font><font color="#0000ff"><font color="#0000ff">&lt;</font></font><font color="#a31515"><font color="#a31515">xs:schema</font></font><font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">xmlns:xs</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">http://www.w3.org/2001/XMLSchema</font></font>"<font color="#0000ff"><font color="#0000ff"> <br />
                     </font></font><font color="#ff0000"><font color="#ff0000">xmlns:vs</font></font><font color="#0000ff"><font color="#0000ff">=</font></font><font color="#0000ff"><font color="#0000ff"><a href="http://schemas.microsoft.com/Visual-Studio-Intellisense">http://schemas.microsoft.com/Visual-Studio-Intellisense</a></font></font><font color="#0000ff"><font color="#0000ff"> <br />
                     </font></font><font color="#ff0000"><font color="#ff0000">elementFormDefault</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">qualified</font></font>"<font color="#0000ff"><font color="#0000ff"> <br />
                     </font></font><font color="#ff0000"><font color="#ff0000">attributeFormDefault</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">unqualified</font></font>"<font color="#0000ff"><font color="#0000ff">&gt;
<p></p></font></font><font color="#0000ff"><font color="#0000ff"><p>
   &lt;
</p></font></font><font color="#a31515"><font color="#a31515">xs:element</font></font><font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">name</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">fileRepositories</font></font>"<font color="#0000ff"><font color="#0000ff">&gt;<br />
      &lt;</font></font><font color="#a31515"><font color="#a31515">xs:complexType</font></font><font color="#0000ff"><font color="#0000ff">&gt;<br />
         &lt;</font></font><font color="#a31515"><font color="#a31515">xs:choice</font></font><font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">minOccurs</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">0</font></font>"<font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">maxOccurs</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">unbounded</font></font>"<font color="#0000ff"><font color="#0000ff">&gt;<br />
            &lt;</font></font><font color="#a31515"><font color="#a31515">xs:element</font></font><font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">name</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">fileRepository</font></font>"<font color="#0000ff"><font color="#0000ff">&gt;<br />
               &lt;</font></font><font color="#a31515"><font color="#a31515">xs:complexType</font></font><font color="#0000ff"><font color="#0000ff">&gt;<br />
                  &lt;</font></font><font color="#a31515"><font color="#a31515">xs:attribute</font></font><font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">name</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">id</font></font>"<font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">type</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">xs:string</font></font>"<font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">use</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">required</font></font>"<font color="#0000ff"><font color="#0000ff"> /&gt;<br />
                  &lt;</font></font><font color="#a31515"><font color="#a31515">xs:attribute</font></font><font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">name</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">isDefault</font></font>"<font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">type</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">xs:boolean</font></font>"<font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">default</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">false</font></font>"<font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">use</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">optional</font></font>"<font color="#0000ff"><font color="#0000ff">/&gt;<br />
                  &lt;</font></font><font color="#a31515"><font color="#a31515">xs:attribute</font></font><font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">name</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">connectionString</font></font>"<font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">type</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">xs:string</font></font>"<font color="#0000ff"><font color="#0000ff"></font></font><font color="#ff0000"><font color="#ff0000">use</font></font><font color="#0000ff"><font color="#0000ff">=</font></font>"<font color="#0000ff"><font color="#0000ff">required</font></font>"<font color="#0000ff"><font color="#0000ff">/&gt;<br />
               &lt;/</font></font><font color="#a31515"><font color="#a31515">xs:complexType</font></font><font color="#0000ff"><font color="#0000ff">&gt;<br />
            &lt;/</font></font><font color="#a31515"><font color="#a31515">xs:element</font></font><font color="#0000ff"><font color="#0000ff">&gt;<br />
         &lt;/</font></font><font color="#a31515"><font color="#a31515">xs:choice</font></font><font color="#0000ff"><font color="#0000ff">&gt;<br />
      &lt;/</font></font><font color="#a31515"><font color="#a31515">xs:complexType</font></font><font color="#0000ff"><font color="#0000ff">&gt;<br />
   &lt;/</font></font><font color="#a31515"><font color="#a31515">xs:element</font></font><font color="#0000ff"><font color="#0000ff">&gt;<br />
&lt;/</font></font><font color="#a31515"><font color="#a31515">xs:schema</font></font><font color="#0000ff"><font color="#0000ff">&gt;
</font></font></font>
          </font>
        </font>
        <p>
          <font color="#0000ff" size="3">
            <font color="#0000ff" size="3">
              <font color="#000000" size="2">I
placed this file in the ...\Xml\Schemas folder in the Visual Studio installation folder
as noted above. Now, to hook this into VS, you need to add it to the xsd catalog.
You do this by editing the file <strong>catalog.xml</strong>. Add the following line
to the bottom of this file before the closing &lt;schemaCatalog&gt; tag:</font>
            </font>
          </font>
        </p>
        <p>
          <font color="#0000ff" size="3">
            <font color="#0000ff" size="3">
              <font color="#000000" size="2"> 
&lt;Association extension="config" schema="%InstallRoot%/xml/schemas/MyConfig.xsd"
condition="%TargetFrameworkVersion% != 2.0 and %TargetFrameworkVersion% != 3.0" /&gt;<br /></font>
            </font>
          </font>
        </p>
        <p>
          <font color="#0000ff" size="3">
            <font color="#0000ff" size="3">
              <font color="#000000" size="2">That's
it! Now when you go into VS and edit a config file, you'll get Intellisense!</font>
            </font>
          </font>
        </p>
        <p>
          <font color="#0000ff" size="3">
            <font color="#0000ff" size="3">
              <font color="#000000" size="2"> 
</font>
            </font>
          </font>
        </p>
        <img src="http://blog.whconsult.com/content/binary/configIntellisense.png" border="0" />
        <img width="0" height="0" src="http://blog.whconsult.com/aggbug.ashx?id=1978f9ec-2e78-4d4d-af60-6507d3a91698" />
      </body>
      <title>Adding Intellisense to Visual Studio for Custom Configuration Sections</title>
      <guid isPermaLink="false">http://blog.whconsult.com/PermaLink,guid,1978f9ec-2e78-4d4d-af60-6507d3a91698.aspx</guid>
      <link>http://blog.whconsult.com/2008/11/20/AddingIntellisenseToVisualStudioForCustomConfigurationSections.aspx</link>
      <pubDate>Thu, 20 Nov 2008 13:57:11 GMT</pubDate>
      <description>&lt;p&gt;
Intellisense is wonderful. It's so useful it's actually scary because it doesn't force
you to remember a lot class names, enum values, etc. This is good for productivity
but bad when you need to recall something without the Visual Studio IDE!
&lt;/p&gt;
&lt;p&gt;
In any case, I like to get Intellisense whenever I can. One area that I kept putting
off was adding Intellisense for custom configuration sections I create. I dislike
loads of &amp;lt;add&amp;gt; tags in the &amp;lt;appSettings&amp;gt; section because it becomes hard
to navigate. I prefer to create custom config sections. However, I don't get the benefit
- out of the box - of Intellisense and schema validation. To get this, you need to
create your own XSD file to support your custom config sections.
&lt;/p&gt;
&lt;p&gt;
XSDs for config sections are not hard to write. In fact, its best to just take a look
at the XSD file for the .NET config file which can be found in your Visual Studio
installation folder. For example, on my machine for VS 2008, I navigate to:
&lt;/p&gt;
&lt;p&gt;
C:\Program Files\Microsoft Visual Studio 9.0\Xml\Schemas
&lt;/p&gt;
&lt;p&gt;
Here you'll find loads of XSD files for all sorts of things. The most important one
however is called DotNetConfig.xsd. This contains the schema definitions for the base
.NET config file. There are also supplimental files for .NET 2.0 and 3.0 config sections
in DotNetConfig20.xsd and DotNetConfig30.xsd respectively.
&lt;/p&gt;
&lt;p&gt;
Here's a simple example of a config section:
&lt;/p&gt;
&lt;font color=#0000ff size=3&gt;&lt;font color=#0000ff size=3&gt; 
&lt;p&gt;
&lt;font size=2&gt;&amp;lt;&lt;/font&gt;
&lt;/font&gt;&lt;/font&gt;&lt;font color=#a31515&gt;&lt;font color=#a31515&gt;fileRepositories&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#a31515&gt;&lt;font color=#a31515&gt;fileRepository&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000&gt;&lt;font color=#ff0000&gt;id&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;=&lt;/font&gt;&lt;/font&gt;&lt;font color=#000000&gt;"&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;MainLib&lt;/font&gt;&lt;/font&gt;&lt;font color=#000000&gt;"&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000&gt;&lt;font color=#ff0000&gt;isDefault&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;=&lt;/font&gt;&lt;/font&gt;&lt;font color=#000000&gt;"&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;true&lt;/font&gt;&lt;/font&gt;&lt;font color=#000000&gt;"&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000&gt;&lt;font color=#ff0000&gt;connectionString&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;=&lt;/font&gt;&lt;/font&gt;&lt;font color=#000000&gt;"&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;\\JUPITER\MainLib&lt;/font&gt;&lt;/font&gt;&lt;font color=#000000&gt;"&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt; /&amp;gt;&lt;br&gt;
&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;font color=#a31515&gt;&lt;font color=#a31515&gt;fileRepositories&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;&amp;gt;&lt;/font&gt;&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font color=#0000ff size=3&gt;&lt;font color=#0000ff size=3&gt;&lt;font color=#000000 size=2&gt;The
xsd schema (MyConfig.xsd) for this config section is:&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;font color=#0000ff size=3&gt;&lt;font color=#0000ff size=3&gt;&lt;font color=#000000 size=2&gt;&lt;font color=#0000ff size=3&gt;&lt;font color=#0000ff size=3&gt; 
&lt;p&gt;
&lt;font size=2&gt;&amp;lt;?&lt;/font&gt;
&lt;/font&gt;&lt;/font&gt;&lt;font color=#a31515&gt;&lt;font color=#a31515&gt;xml&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000&gt;&lt;font color=#ff0000&gt;version&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;=&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;1.0&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000&gt;&lt;font color=#ff0000&gt;encoding&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;=&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;us-ascii&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;?&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#a31515&gt;&lt;font color=#a31515&gt;xs:schema&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000&gt;&lt;font color=#ff0000&gt;xmlns:xs&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;=&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;http://www.w3.org/2001/XMLSchema&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000&gt;&lt;font color=#ff0000&gt;xmlns:vs&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;=&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;&lt;a href="http://schemas.microsoft.com/Visual-Studio-Intellisense"&gt;http://schemas.microsoft.com/Visual-Studio-Intellisense&lt;/a&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000&gt;&lt;font color=#ff0000&gt;elementFormDefault&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;=&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;qualified&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000&gt;&lt;font color=#ff0000&gt;attributeFormDefault&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;=&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;unqualified&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;&amp;gt;&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt; 
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;
&lt;/font&gt;&lt;/font&gt;&lt;font color=#a31515&gt;&lt;font color=#a31515&gt;xs:element&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000&gt;&lt;font color=#ff0000&gt;name&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;=&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;fileRepositories&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#a31515&gt;&lt;font color=#a31515&gt;xs:complexType&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#a31515&gt;&lt;font color=#a31515&gt;xs:choice&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000&gt;&lt;font color=#ff0000&gt;minOccurs&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;=&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;0&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000&gt;&lt;font color=#ff0000&gt;maxOccurs&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;=&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;unbounded&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#a31515&gt;&lt;font color=#a31515&gt;xs:element&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000&gt;&lt;font color=#ff0000&gt;name&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;=&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;fileRepository&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#a31515&gt;&lt;font color=#a31515&gt;xs:complexType&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#a31515&gt;&lt;font color=#a31515&gt;xs:attribute&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000&gt;&lt;font color=#ff0000&gt;name&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;=&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;id&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000&gt;&lt;font color=#ff0000&gt;type&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;=&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;xs:string&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000&gt;&lt;font color=#ff0000&gt;use&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;=&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;required&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt; /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#a31515&gt;&lt;font color=#a31515&gt;xs:attribute&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000&gt;&lt;font color=#ff0000&gt;name&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;=&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;isDefault&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000&gt;&lt;font color=#ff0000&gt;type&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;=&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;xs:boolean&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000&gt;&lt;font color=#ff0000&gt;default&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;=&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;false&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000&gt;&lt;font color=#ff0000&gt;use&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;=&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;optional&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#a31515&gt;&lt;font color=#a31515&gt;xs:attribute&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000&gt;&lt;font color=#ff0000&gt;name&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;=&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;connectionString&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000&gt;&lt;font color=#ff0000&gt;type&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;=&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;xs:string&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt; &lt;/font&gt;&lt;/font&gt;&lt;font color=#ff0000&gt;&lt;font color=#ff0000&gt;use&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;=&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;required&lt;/font&gt;&lt;/font&gt;"&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;font color=#a31515&gt;&lt;font color=#a31515&gt;xs:complexType&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;font color=#a31515&gt;&lt;font color=#a31515&gt;xs:element&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;font color=#a31515&gt;&lt;font color=#a31515&gt;xs:choice&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;font color=#a31515&gt;&lt;font color=#a31515&gt;xs:complexType&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;font color=#a31515&gt;&lt;font color=#a31515&gt;xs:element&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;&amp;gt;&lt;br&gt;
&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;font color=#a31515&gt;&lt;font color=#a31515&gt;xs:schema&lt;/font&gt;&lt;/font&gt;&lt;font color=#0000ff&gt;&lt;font color=#0000ff&gt;&amp;gt;&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt; 
&lt;p&gt;
&lt;font color=#0000ff size=3&gt;&lt;font color=#0000ff size=3&gt;&lt;font color=#000000 size=2&gt;I
placed this file in the ...\Xml\Schemas folder in the Visual Studio installation folder
as noted above. Now, to hook this into VS, you need to add it to the xsd catalog.
You do this by editing the file &lt;strong&gt;catalog.xml&lt;/strong&gt;. Add the following line
to the bottom of this file before the closing &amp;lt;schemaCatalog&amp;gt; tag:&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0000ff size=3&gt;&lt;font color=#0000ff size=3&gt;&lt;font color=#000000 size=2&gt;&amp;nbsp;
&amp;lt;Association extension="config" schema="%InstallRoot%/xml/schemas/MyConfig.xsd"
condition="%TargetFrameworkVersion% != 2.0 and %TargetFrameworkVersion% != 3.0" /&amp;gt;&lt;br&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0000ff size=3&gt;&lt;font color=#0000ff size=3&gt;&lt;font color=#000000 size=2&gt;That's
it! Now when you go into VS and edit a config file, you'll get Intellisense!&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0000ff size=3&gt;&lt;font color=#0000ff size=3&gt;&lt;font color=#000000 size=2&gt;&amp;nbsp;
&lt;/p&gt;
&gt;&gt;&gt;&lt;img src="http://blog.whconsult.com/content/binary/configIntellisense.png" border=0&gt;&lt;img width="0" height="0" src="http://blog.whconsult.com/aggbug.ashx?id=1978f9ec-2e78-4d4d-af60-6507d3a91698" /&gt;</description>
      <comments>http://blog.whconsult.com/CommentView,guid,1978f9ec-2e78-4d4d-af60-6507d3a91698.aspx</comments>
      <category>Configuration</category>
    </item>
  </channel>
</rss>