Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/302.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ';配置节不能包含CDATA或文本元素';使用App.config和cs文件时出错_C#_Xml_Typeinitializeexception - Fatal编程技术网

C# ';配置节不能包含CDATA或文本元素';使用App.config和cs文件时出错

C# ';配置节不能包含CDATA或文本元素';使用App.config和cs文件时出错,c#,xml,typeinitializeexception,C#,Xml,Typeinitializeexception,我收到一条配置部分不能在下面的代码行中包含CDATA或文本元素的错误消息。此数组中使用Config.HeaderBaseLocation时发生错误 var header = stream[Config.HeaderBaseLocation].Split(Seperators); 我相信这是因为我的代码中有一个无效字符,但我似乎找不到它。我还应该注意,这是在我的代码中使用的任何Config变量的第一次出现 下面是我正在使用的代码 App.config <appSettings>

我收到一条
配置部分不能在下面的代码行中包含CDATA或文本元素的错误消息。此数组中使用
Config.HeaderBaseLocation
时发生错误

var header = stream[Config.HeaderBaseLocation].Split(Seperators);
我相信这是因为我的代码中有一个无效字符,但我似乎找不到它。我还应该注意,这是在我的代码中使用的任何
Config
变量的第一次出现

下面是我正在使用的代码

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"]);
}
公共静态类配置{
//CROZZLE:网格的填充量。
内部静态uint croylepadding=uint.Parse(AppSettings[“croylepadding”]);
//CROZZLE.TXT:标题分配约束值
内部静态int-WordCountMin=>int.Parse(AppSettings[“WordCountMin]”);
内部静态int-WordCountMax=>int.Parse(AppSettings[“WordCountMax”]);
内部静态int-RowCountMin=>int.Parse(AppSettings[“RowCountMin]”);
内部静态int-RowCountMax=>int.Parse(AppSettings[“RowCountMax]”);
内部静态int-ColumnCountMin=>int.Parse(AppSettings[“ColumnCountMin]”);
内部静态int-ColumnCountMax=>int.Parse(AppSettings[“ColumnCountMax”]);
//CROZZLE.TXT:行的预期长度值
内部静态int-HeaderExpectedLength=>int.Parse(AppSettings[“HeaderExpectedLength]”);
内部静态int-WordDataExpectedLength=>int.Parse(AppSettings[“WordDataExpectedLength”]);
//CROZZLE.TXT:文件中的预期值位置
内部静态int-HeaderBaseLocation=>int.Parse(AppSettings[“HeaderBaseLocation”]);
内部静态int-WordListBaseLocation=>int.Parse(AppSettings[“WordListBaseLocation”]);
//CROZZLE.TXT:预期的标题值位置
内部静态int-HeaderDifficultyLocation=>int.Parse(AppSettings[“HeaderDifficultyLocation]”);
内部静态int-HeaderWordCountLocation=>int.Parse(AppSettings[“HeaderWordCountLocation”]);
内部静态int-HeaderRowCountLocation=>int.Parse(AppSettings[“HeaderRowCountLocation]”);
内部静态int-HeaderColumnCountLocation=>int.Parse(AppSettings[“HeaderColumnCountLocation]”);
内部静态int-HeaderHorizontalWordCountLocation=>int.Parse(AppSettings[“HeaderHorizontalWordCountLocation]”);
内部静态int-HeadServerTicalwordCountLocation=>int.Parse(AppSettings[“HeadServerTicalwordCountLocation”]);
//CROZZLE.TXT:预期的WORDDATA值位置
内部静态int-WordDataDirectionLocation=>int.Parse(AppSettings[“WordDataDirectionLocation]”);
内部静态int-WordDataRowLocation=>int.Parse(AppSettings[“WordDataRowLocation”]);
内部静态int-WordDataColumnLocation=>int.Parse(AppSettings[“WordDataColumnLocation”]);
内部静态int-WordDataWordLocation=>int.Parse(AppSettings[“WordDataWordLocation”]);
//CONFIGURATION.TXT:相交和非相交值索引
内部静态int-LetterValueIndex=>int.Parse(AppSettings[“LetterValueIndex]”);
内部静态int-lettscoreIndex=>int.Parse(AppSettings[“lettscoreIndex]”);
内部静态int-ExpectedConfigurationGroupAndPointValuesCount=>int.Parse(AppSettings[“ExpectedConfigurationGroupAndPointValuesCount]”);
内部静态int-ExpectedConfigurationIntersectAndNonIntersectValuesCount=>int.Parse(应用程序设置[“ExpectedConfigurationIntersectAndNonIntersectValuesCount]”);
//CONFIGURATION.TXT:文件中的预期值位置
内部静态int-GroupsPerCrozzleIndex=>int.Parse(AppSettings[“GroupsPerCrozzleIndex]”);
内部静态int pointsperOrdindex=>int.Parse(AppSettings[“pointsperOrdindex]”);
内部静态范围IntersectingLetterIndex=>新范围(int.Parse(AppSettings[“IntersectingLetterIndexMin”])、int.Parse(AppSettings[“IntersectingLetterIndexMax”]);
内部静态范围NonIntersectingLetterIndex=>新范围(int.Parse(AppSettings[“NonIntersectingLetterIndexMin]”)、int.Parse(AppSettings[“NonIntersectingLetterIndexMax]”);
//CONFIGURATION.TXT:检查验证程序时出错
内部静态int-LettersInAlphabetCount=>int.Parse(AppSettings[“LettersInAlphabetCount]”);
//CONFIGURATION.TXT:需要在FILS中查找的预期配置值位置和标题(需要剔除的预期POINTDATA值)
内部静态字符串[]ExpectedConfigurationFileValues=>Array.ConvertAll(AppSettings[“GroupSpercrozleNameIndex”].Split(“;”),p=>p.Trim());
内部静态int-GroupsPerCrozzleNameIndex=>int.Parse(AppSettings[“GroupsPerCrozzleNameIndex]”);
内部静态int PointsPerWordNameIndex=>int.Parse(AppSettings[“PointsPerWordNameIndex]”);
内部静态int IntersectingLetterNameIndex=>int.Parse(AppSettings[“IntersectingLetterNameIndex]”);
内部静态int NonIntersectingLetterNameIndex=>int.Parse(AppSettings[“NonIntersectingLetterNameIndex]”);
}

您的一条评论旁边有一个零散的
/

您的一条评论旁边有一个零散的
/

代码在哪里?啊,找到了。干杯密码在哪里?啊,找到了。干杯