1

我在我的一个 C# 批处理作业中遇到了一个奇怪的错误,因此我决定逐个重建它以找出导致问题的原因。原来它是一种ConfigurationErrorsException我以前从未见过的叫做 a 的东西。这是内部异常:

Configuration system failed to initialize System.Exception {System.Configuration.ConfigurationErrorsException}

`

当我尝试通过访问app.config. 以下是我到目前为止的全部代码

using System;
using BatchDashboard;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Diagnostics;
using IBM.WMQ;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using System.Xml;


namespace LVODRM
{
    class Program
    {
        //Job log and BatchDashboard variables
        private static StreamWriter _Log;
        //public static string _environment = getEnvironment();
        public const string _PACKAGENAME = "LVOONX";

        //BatchDashboard variables
        public static int xmlRecordCount = 0;
        public static int xmlProcessedCount = 0;
        public static int errorCount = 0;
        public static int warningCount = 0;

        //MQ and Parsing variables
        public static string strReturn;
        public static string queueName;
        public static string pathToSave;
        public static string strQueueManager;
        public static int backOutNumberThreshold;

        static void Main(string[] args)
        {
            strReturn = string.Empty;
            queueName = ConfigurationManager.AppSettings.Get("QueueName");

            Console.Write("Hello world");
            Console.ReadKey();
        }
    }
}   

这是我的 app.config 文件。有人能告诉我我错过了什么吗?

<?xml version="1.0"?>
<configuration>
  <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
    <section name="LVODRM.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </sectionGroup>
  <!--MQ SETTINGS-->
  <add key="QueueName" value="LVO.DRM.PRODUCER.NEWAPT"/>
  <add key="PathToSave" value="\\prdhilfs02\L&amp;I-SYSTEMS\WORKAREA\AgencySystems\Public\NMF_Onyx\NMFDatafiles\NMFImportFiles\"/>
  <add key="QueueManager" value="MQT_DMB01"/>
  <add key="BackOutNumberThreshold" value="10"/>

</configuration>
4

1 回答 1

3

您缺少<appSettings>标签。例如:

<appSettings>
    <add key="QueueName" value="LVO.DRM.PRODUCER.NEWAPT"/>
    ...
</appSettings>
于 2013-06-07T20:03:06.440 回答