3

C#WebアプリケーションでMonorailを使用しています。アップグレードしたので(.Net Framework2から4およびMonorail1.0.3から2.1RC)、ViewComponentクラスが見つかりません。私のコントローラーはすべて正常に動作しているようです。nVelocityViewEngineを使用しています。私はウィンザーを使用していませんが、多分今、私はそれを特定の方法で登録することになっていますか?

.vmファイルで、次の行を実験しました(成功せず、プロジェクトをアップグレードする前に最初の行が機能していました):

 #component(MenuComponent)
 #component(MenuComponent with "role=admins")
 #blockcomponent(MenuComponent with "role=admins")

誰かがそれを実験しましたか?

完全なエラーメッセージは次のとおりです。

ViewComponent'MenuComponent'が見つかりませんでした。登録されましたか?Windsor Integrationを有効にしている場合は、ビューコンポーネントをWindsorコンポーネントとして登録するのを忘れている可能性があります。確実に実行した場合は、使用する名前がコンポーネントIDまたはViewComponentDetailsAttributeに渡されたキーであることを確認してください。

どうもありがとう!

4

2 に答える 2

1

私はついに自分の問題の手がかりを見つけました。「Castle.Monorail.Framework.dll」ソースコードを使用して、内部で何が起こっているかを確認しました。Web.Configファイル(<Controllers>またはでさえ<viewcomponents>)で指定されたアセンブリは、変数が原因であると想定されているため、「検査」されていないようです。それを含むものは初期化が遅すぎます。

新しいバージョンのdllをビルドしましたが、正常に動作しています。「修正された」コードをCastleProjectCommunityに送信して、他の何か(悪い設定など)の結果ではないことを確認します。

それまでは、ここに私の「修正」があります。コードの一部を移動しただけです。元のソースコードはここにあります:http ://www.symbolsource.org/Public/Metadata/Default/Project/Castle/1.0-RC3/Debug/All/Castle.MonoRail.Framework/Castle.MonoRail.Framework/Services /DefaultViewComponentFactory.cs

*Assembly:* Castle.MonoRail.Framework
*Class:* Castle.MonoRail.Framework.Services.**DefaultViewComponentFactory**


public override void Service(IServiceProvider provider)
{
  /* Here is the section I moved */
  var config = (IMonoRailConfiguration)provider.GetService(typeof(IMonoRailConfiguration));
  if (config != null)
  {
    assemblies = config.ViewComponentsConfig.Assemblies;
    if (assemblies == null || assemblies.Length == 0)
    {
      // Convention: uses the controller assemblies in this case
      assemblies = config.ControllersConfig.Assemblies.ToArray();
    }
  }
  /*******************************/

  base.Service(provider); // Assemblies inspection is done there

  var loggerFactory = (ILoggerFactory) provider.GetService(typeof(ILoggerFactory));
  if (loggerFactory != null)
  {
    logger = loggerFactory.Create(typeof(DefaultViewComponentFactory));
  }
  /* The moved section was here */
}
于 2011-06-20T15:36:52.220 に答える
0

私はあなたの修正なしで、MenuComponentの名前をMenuだけに変更した場合、それは機能するのでしょうか?

于 2012-08-21T22:40:21.253 に答える