Castle[.net2.0] tips-1: Windsor注册ViewComponent的名称区分大小写

 

  在Monorail集成了Windsor后,所有Controller和ViewComponent都要向WindsorContainer注册.

 

AddComponent( " Menu " , typeof (MenuComponent));

 

调用时 [NVelocity]

 

< div id = " menu " > #component(MenuComponent) </ div >

 

错位现象:

 

第一次我在注册时使用的是

 

AddComponent( " menu " typeof (MenuComponent));
 

按上边方法调用报错: 找不到MenuComponent,提示我可能没向WindsorContainer注册.

 

Castle.MonoRail.Framework.RailsException: ViewComponent  ' menuComponent '  could not be found. Was it registered ?  If you have enabled Windsor Integration, then it ' s likely that you have forgot to register the view component as a Windsor component. If you are sure you did it, then make sure the name used is the component id or the key passed to ViewComponentDetailsAttribute
   在 Castle.MonoRail.Framework.Services.DefaultViewComponentRegistry.GetViewComponent(String name)
   在 Castle.MonoRail.Framework.Services.AbstractViewComponentFactory.ResolveType(String name)
   在 Castle.MonoRail.WindsorExtension.WindsorViewComponentFactory.Create(String name)
   在 Castle.MonoRail.Framework.Views.NVelocity.CustomDirectives.AbstractComponentDirective.Render(IInternalContextAdapter context, TextWriter writer, INode node)
   在 NVelocity.Runtime.Parser.Node.ASTDirective.Render(IInternalContextAdapter context, TextWriter writer)
   在 NVelocity.Runtime.Parser.Node.SimpleNode.Render(IInternalContextAdapter context, TextWriter writer)
   在 NVelocity.Template.Merge(IContext context, TextWriter writer)
   在 Castle.MonoRail.Framework.Views.NVelocity.NVelocityViewEngine.RenderLayout(String layoutName, String contents, IContext ctx, IRailsEngineContext context, TextWriter output)

 

后改为这样调用

 

< div id = " menu " > #component( menu Component) </ div >

 

一切正常了.

 

注意: NVelocity调用component时使用的不是 component类的类名 而是 Component类在 WindsorContainer中的注册名,此注册名严格区分大小写,在NVelocity中引用时请万分注意.希望高手开发一个NVelocity的只能提示,或可减少此类问题的困扰.

转载于:https://www.cnblogs.com/quiary/archive/2011/09/16/2178324.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值