parsing issue at save time

Topics: General discussion
Oct 10, 2007 at 4:32 PM
Hello,

I have an issue when trying to save a .config xml file in the EntLibConfig.exe tool. My .config file is generated with another tool and all XML tags have an opening and a closing tag. The following tag is causing an error on the "add" element when saving the file:
<configProtectedData>
<providers>
<clear>
</clear>
<add name="RsaProtectedConfigurationProvider" type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" keyContainerName="test" useMachineContainer="true">
</add>
</providers>
</configProtectedData>

If i replace <clear></clear> with <clear /> it works just fine. Any idea about this issue? Thanks!
Oct 11, 2007 at 1:10 PM
Hi,

It's really the System.Configuration assembly that parses the configuration file, so there is little that can be done about this.

If you try editing this config file with the standard VS editor you will get a warning stating that the <clear> element cannot have white space, and if you read the configuration the connection strings will be empty.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<clear>
</clear>
<add name="foo" connectionString="bar"/>
<add name="foo2" connectionString="bar"/>
</connectionStrings>
</configuration>

static void Main(string[] args)
{
Debug.Assert(ConfigurationManager.ConnectionStrings.Count == 2, "should have 2 connection strings");
}

Fernando