2

{"構成システムの初期化に失敗しました"}

作成した Windows アプリケーションを実行しようとすると、このエラーが発生します。これは、Castle Windsor が app.config から構成を初期化できなかったことを意味します。

面白いことに、私のテスト プロジェクトは機能し、同じ app.config を初期化できますが、それを Windows アプリケーションに移動して同じコードを使用すると失敗しました。

どんな助けでも大歓迎です、

前もって感謝します


構成コード:

  <configSections>
<section
    name="castle"
    type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor" /></configSections>

  <castle>
<components>
  <component id="UserRepository"
             service="Abstract.IDAO`2[[BusniessEntities.User,BusniessEntities],[System.Int32]],Abstract"
             type="Concrete.SqlUserRepository,Concrete"/>
</components>

これはC#コードです:

WindsorContainer _container = new WindsorContainer(new XmlInterpreter(new ConfigResource("castle")));

テストプロジェクトで同じコードが機能します。しかし、Windowsアプリケーションではありません。

4

1 に答える 1

3

私はそれを解決しました

 <configuration><startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>  </startup>  <configSections><section
    name="castle"        type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler,Castle.Windsor" /></configSections>
  <castle>
<components>
  <component id="UserRepository"
             service="Abstract.IDAO`2[[BusniessEntities.User,BusniessEntities],[System.Int32]],Abstract"
             type="Concrete.SqlUserRepository,Concrete"/>
</components>

configセクションは何よりも前になければなりませんでした。テストプロジェクトではapp.configに起動タグがなかったため機能しましたが、Windowsアプリケーションではapp.configに起動タグがあるため、configsectionを上に移動する必要がありました

于 2010-07-25T06:48:50.630 に答える