I'm receiving a The configuration section cannot contain a CDATA or text element
error message in the following line of code. The error is occurring when Config.HeaderBaseLocation
is being used in this array.
var header = stream[Config.HeaderBaseLocation].Split(Seperators);
I believe this is occurring because there is an invalid character in my code, but I cannot seem to find it. I should also note that this is the first occurrence of any of the Config
variables being used in my code.
Below is the code I am using...
App.config
<appSettings>
<!--
CROZZLE.TXT
-->
<!-- HEADER ASSIGNMENT CONSTRAINT VALUES -->
<add key="WordCountMin" value="10"/>
<add key="WordCountMax" value="1000"/>
<add key="RowCountMin" value="4"/>
<add key="RowCountMax" value="400"/>
<add key="ColumnCountMin" value="8"/>
<add key="ColumnCountMax" value="800"/>
<!-- EXPECTED LENGTH VALUES FOR A ROW -->
<add key="HeaderExpectedLength" value="6"/>
<add key="WordDataExpectedLength" value="4"/>
<!-- EXPECTED VALUE LOCATIONS IN FILE -->
<add key="HeaderBaseLocation" value="0"/>
<add key="WordListBaseLocation" value="1"/>
<!-- EXPECTED HEADER VALUE LOCATIONS -->
<add key="HeaderDifficultyLocation" value="0"/>
<add key="HeaderWordCountLocation" value="1"/>
<add key="HeaderRowCountLocation" value="2"/>
<add key="HeaderColumnCountLocation" value="3"/>
<add key="HeaderHorizontalWordCountLocation" value="4"/>
<add key="HeaderVerticalWordCountLocation" value="5"/>
<!-- EXPECTED WORDDATA VALUE LOCATIONS -->
<add key="WordDataDirectionLocation" value="0"/>
<add key="WordDataRowLocation" value="1"/>
<add key="WordDataColumnLocation" value="2"/>
<add key="WordDataWordLocation" value="3"/>
<!-- PADDING AMOUNT FOR THE GRID -->
<add key="CrozzlePadding" value="2"/>
<!--
CONFIGURATION.TXT
-->
<!-- INTERSECTING AND NONINTERSECTING VALUE INDEXES -->
<add key="LetterValueIndex" value="0"/>
<add key="LetterScoreIndex" value="1"/>
<add key="ExpectedConfigurationGroupAndPointValuesCount" value="2"/>
<add key="ExpectedConfigurationIntersectAndNonIntersectValuesCount" value="3"/>
<!-- EXPECTED VALUE LOCATIONS IN THE CONGIGURATION FILE -->
<add key="GroupsPerCrozzleIndex" value="0"/>
<add key="PointsPerWordIndex" value="1"/>
<add key="IntersectingLetterIndexMin" value="2"/>
<add key="IntersectingLetterIndexMax" value="27"/>
<add key="NonIntersectingLetterIndexMin" value="28"/>
<add key="NonIntersectingLetterIndexMax" value="53"/>
<!-- ERROR CHECKING VALIDATORS -->
<add key="LettersInAlphabetCount" value="26"/>
/<!-- EXPECTED CONFIGURATION VALUE LOCATIONS AND TITLES TO LOOK FOR IN THE FILS (EXPECTED POINTDATA VALUES TO CULL) -->
<add key="ExpectedConfigurationFileValues" value="GROUPSPERCROZZLELIMIT ; POINTSPERWORD ; INTERSECTING ; NONINTERSECTING" />
<add key="GroupsPerCrozzleNameIndex" value="0"/>
<add key="PointsPerWordNameIndex" value="1"/>
<add key="IntersectingLetterNameIndex" value="2"/>
<add key="NonIntersectingLetterNameIndex" value="3"/>
</appSettings>
Config.cs
public static class Config {
//CROZZLE : PADDING AMOUNT FOR THE GRID.
internal static uint CrozzlePadding = uint.Parse(AppSettings["CrozzlePadding"]);
// CROZZLE.TXT : HEADER ASSIGNMENT CONSTRAINT VALUES
internal static int WordCountMin => int.Parse(AppSettings["WordCountMin"]);
internal static int WordCountMax => int.Parse(AppSettings["WordCountMax"]);
internal static int RowCountMin => int.Parse(AppSettings["RowCountMin"]);
internal static int RowCountMax => int.Parse(AppSettings["RowCountMax"]);
internal static int ColumnCountMin => int.Parse(AppSettings["ColumnCountMin"]);
internal static int ColumnCountMax => int.Parse(AppSettings["ColumnCountMax"]);
// CROZZLE.TXT : EXPECTED LENGTH VALUES FOR A ROW
internal static int HeaderExpectedLength => int.Parse(AppSettings["HeaderExpectedLength"]);
internal static int WordDataExpectedLength => int.Parse(AppSettings["WordDataExpectedLength"]);
// CROZZLE.TXT : EXPECTED VALUE LOCATIONS IN FILE
internal static int HeaderBaseLocation => int.Parse(AppSettings["HeaderBaseLocation"]);
internal static int WordListBaseLocation => int.Parse(AppSettings["WordListBaseLocation"]);
// CROZZLE.TXT : EXPECTED HEADER VALUE LOCATIONS
internal static int HeaderDifficultyLocation => int.Parse(AppSettings["HeaderDifficultyLocation"]);
internal static int HeaderWordCountLocation => int.Parse(AppSettings["HeaderWordCountLocation"]);
internal static int HeaderRowCountLocation => int.Parse(AppSettings["HeaderRowCountLocation"]);
internal static int HeaderColumnCountLocation => int.Parse(AppSettings["HeaderColumnCountLocation"]);
internal static int HeaderHorizontalWordCountLocation => int.Parse(AppSettings["HeaderHorizontalWordCountLocation"]);
internal static int HeaderVerticalWordCountLocation => int.Parse(AppSettings["HeaderVerticalWordCountLocation"]);
// CROZZLE.TXT : EXPECTED WORDDATA VALUE LOCATIONS
internal static int WordDataDirectionLocation => int.Parse(AppSettings["WordDataDirectionLocation"]);
internal static int WordDataRowLocation => int.Parse(AppSettings["WordDataRowLocation"]);
internal static int WordDataColumnLocation => int.Parse(AppSettings["WordDataColumnLocation"]);
internal static int WordDataWordLocation => int.Parse(AppSettings["WordDataWordLocation"]);
// CONFIGURATION.TXT : INTERSECTING AND NONINTERSECTING VALUE INDEXES
internal static int LetterValueIndex => int.Parse(AppSettings["LetterValueIndex"]);
internal static int LetterScoreIndex => int.Parse(AppSettings["LetterScoreIndex"]);
internal static int ExpectedConfigurationGroupAndPointValuesCount => int.Parse(AppSettings["ExpectedConfigurationGroupAndPointValuesCount"]);
internal static int ExpectedConfigurationIntersectAndNonIntersectValuesCount => int.Parse(AppSettings["ExpectedConfigurationIntersectAndNonIntersectValuesCount"]);
// CONFIGURATION.TXT : EXPECTED VALUE LOCATIONS IN THE FILE
internal static int GroupsPerCrozzleIndex => int.Parse(AppSettings["GroupsPerCrozzleIndex"]);
internal static int PointsPerWordIndex => int.Parse(AppSettings["PointsPerWordIndex"]);
internal static Range<int> IntersectingLetterIndex => new Range<int>(int.Parse(AppSettings["IntersectingLetterIndexMin"]), int.Parse(AppSettings["IntersectingLetterIndexMax"]));
internal static Range<int> NonIntersectingLetterIndex => new Range<int>(int.Parse(AppSettings["NonIntersectingLetterIndexMin"]), int.Parse(AppSettings["NonIntersectingLetterIndexMax"]));
// CONFIGURATION.TXT : ERROR CHECKING VALIDATORS
internal static int LettersInAlphabetCount => int.Parse(AppSettings["LettersInAlphabetCount"]);
// CONFIGURATION.TXT : EXPECTED CONFIGURATION VALUE LOCATIONS AND TITLES TO LOOK FOR IN THE FILS (EXPECTED POINTDATA VALUES TO CULL)
internal static string[] ExpectedConfigurationFileValues => Array.ConvertAll(AppSettings["GroupsPerCrozzleNameIndex"].Split(';'), p => p.Trim());
internal static int GroupsPerCrozzleNameIndex => int.Parse(AppSettings["GroupsPerCrozzleNameIndex"]);
internal static int PointsPerWordNameIndex => int.Parse(AppSettings["PointsPerWordNameIndex"]);
internal static int IntersectingLetterNameIndex => int.Parse(AppSettings["IntersectingLetterNameIndex"]);
internal static int NonIntersectingLetterNameIndex => int.Parse(AppSettings["NonIntersectingLetterNameIndex"]);
}
You have a stray /
next to one of your comments.