2009-08-03 7 views
5

私はApp.configファイルファイルで変数を格納したい、しかし、すぐに私はApp.configファイルでのappSettingsセクションを追加すると、それは私にこのエラー与える:** AppSettings **セクションをApp.configに追加すると、WPFアプリケーションでエラーが発生するのはなぜですか?私のWPFアプリケーション(複合アプリケーション)で

The type initializer for System.Windows.Application threw an exception.

App.configファイル:私はこれがsince I can get it to work in simple applications like thisの作品を知っている一般的に

<?xml version="1.0" encoding="utf-8" ?> 
    <configuration> 
     <appSettings> 
      <add key="SmartFormMockDirectory" value="C:\test"/> 
     </appSettings> 
    <configSections> 
    </configSections> 
    <system.serviceModel> 
     <bindings> 
     <basicHttpBinding> 
      <binding name="Service1Soap" closeTimeout="00:01:00" openTimeout="00:01:00" 
      receiveTime... 

上記のエラーを引き起こす原因は何か、そしてそれを修正してApp.configファイルに変数を追加するだけです。

+0

タイプ初期化子の例外を除き、あなたがしようとするのInnerExceptionのために問い合わせる必要があります。通常1つあります。この場合、より良い答えが得られました。しかし、Andrewは正しい可能性が高いです。 –

答えて

25

<appSettings>ノードを<configSections>ノードの上に配置していると不平を言っているようです。 <configSections>ノードを先頭に移動してファイルの最初の要素にするか、削除してください(使用していないようです)。 configSections Elementから

If the configSections element is in a configuration file, the configSections element must be the first child element of the configuration element.

+0

良い仕事...... – Jinesh

+0

。+ 1、あなたはそれを釘付けにしました。 – tariq

+0

これは私を馬鹿にしていました!非常に最初の要素としてconfigSectionsを入れても、はそれを解決しました。 –

関連する問題