Modification to ComponentModel should be done via IContributeComponentModelCreation
I *think *if you move the logic there, you won't have threading issues.

Krzysztof

On 2010-04-17 23:04, Jan Limpens wrote:
sorry, wasn't yours and I could not find it on the web anymore. i regret my loud mouth. if one does not know for sure, one should shut up and check the facts :)!

the offending code was this:

public class EngineContextFacility : AbstractFacility
    {
        private EngineContextConcern _engineContextConcern;

        protected override void Init()
        {
            _engineContextConcern = new EngineContextConcern();
            Kernel.ComponentCreated += kernelComponentCreated;
        }

        void kernelComponentCreated(ComponentModel model, object instance)
        {
model.LifecycleSteps.Add(LifecycleStepType.Commission, _engineContextConcern);
        }
    }

    public class EngineContextConcern : ILifecycleConcern
    {
        public void Apply(ComponentModel model, object component)
        {
            if (!(component is UrlHelper))
                return;

            var urlHelper = (UrlHelper)component;
urlHelper.SetContext(MonoRailHttpHandlerFactory.CurrentEngineContext); urlHelper.SetController(MonoRailHttpHandlerFactory.CurrentController, MonoRailHttpHandlerFactory.CurrentControllerContext);
        }
    }


2010/4/17 Krzysztof Koźmic <[email protected] <mailto:[email protected]>>

    oups :D

    If you could trace that post it would be appreciated...
    I'll fix it, or remove or whatever necessary.

    Krzysztof


    On 2010-04-17 03:22, Jan Limpens wrote:
    2010/4/8 Krzysztof Koźmic <[email protected]
    <mailto:[email protected]>>

        I guess it's very unlikely you add/remove lifetime concerns
        at any later point, right?


    I had a facility that was doing just that (if I remember
    correctly). I wasn't actually making use of that added
    functionality, so I removed the facility and the error went away.
    I am without access to the sources right now, but if i am not
    completely mistaken, it was some code I grabbed of your site ;) -
    possible?

     Thanks!
    Jan


        Krzysztof



        On 2010-04-08 03:48, Jan Limpens wrote:
        probably you are right - the exception also comes and goes
        on different spots - which defenitely makes it look like a
        threading issue. I just wonder what causes it.

        it seems to get triggered by the view:

        Exception: Exception on process view: themes\detailbykey
        Last accessed variable: HasOptions
        Stack Trace:
           at
        Castle.MonoRail.Views.Brail.BooViewEngine.HandleException(String
        templateName, BrailBase view, Exception e)
           at
        Castle.MonoRail.Views.Brail.BooViewEngine.RenderView(String
        templateName, BrailBase view)
           at
        Castle.MonoRail.Views.Brail.BooViewEngine.Process(String
        templateName, TextWriter output, IEngineContext context,
        IController controller, IControllerContext controllerContext)
           at
        
Castle.MonoRail.Framework.Services.DefaultViewEngineManager.Process(String
        templateName, TextWriter output, IEngineContext context,
        IController controller, IControllerContext controllerContext)
           at Castle.MonoRail.Framework.Controller.ProcessView()
           at
        Castle.Proxies.ThemesControllerProxy.ProcessView_callback()
           at
        
Castle.Proxies.Invocations.Controller_ProcessView_4.InvokeMethodOnTarget()
           at Castle.DynamicProxy.AbstractInvocation.Proceed()
           at
        
Castle.Facilities.AutomaticTransactionManagement.TransactionInterceptor.Intercept(IInvocation
        invocation)
           at Castle.DynamicProxy.AbstractInvocation.Proceed()
           at Castle.Proxies.ThemesControllerProxy.ProcessView()
           at
        Castle.MonoRail.Framework.Controller.RunActionAndRenderView()

          Exception: Destination array was not long enough. Check
        destIndex and length, and the array's lower bounds.
          Stack Trace:
             at System.Array.Copy(Array sourceArray, Int32
        sourceIndex, Array destinationArray, Int32 destinationIndex,
        Int32 length, Boolean reliable)
           at System.Collections.Generic.List`1.CopyTo(T[] array,
        Int32 arrayIndex)
           at Castle.Core.LifecycleStepCollection.GetCommissionSteps()
           at
        
Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.ApplyCommissionConcerns(Object
        instance)
           at
        
Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext
        context)
           at
        
Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext
        context)
           at
        
Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext
        context)
           at
        Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext
        context, Boolean track)
           at
        Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext
        context)
           at
        Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler
        handler, Type service, IDictionary additionalArguments)
           at
        Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler
        handler, Type service)
           at Castle.MicroKernel.DefaultKernel.get_Item(Type service)
           at
        
Castle.MonoRail.WindsorExtension.WindsorViewComponentFactory.Create(String
        name)
           at BrailView_default.$Run$closure$1.Invoke(TextWriter
        OutputStream)
           at
        CompilerGenerated.__BrailView_default_Run$callable0$1_1__.Call(Object[]
        args)
           at
        
Castle.MonoRail.Views.Brail.BrailViewComponentContext.RenderBody(TextWriter
        writer)
           at
        Castle.MonoRail.Framework.ViewComponent.RenderBody(TextWriter writer)
           at Shop.Web.Site.MVC.Components.TileComponent.Render()
           at BrailView_default.Run()
           at
        Castle.MonoRail.Views.Brail.BrailBase.OutputSubView(String
        subviewName, TextWriter writer, IDictionary parameters)
           at
        Castle.MonoRail.Views.Brail.BrailViewComponentContext.RenderView(String
        name, TextWriter writer)
           at
        Castle.MonoRail.Framework.ViewComponent.RenderView(String
        name, TextWriter writer)
           at Shop.Web.Site.MVC.Components.ArticleTileComponent.Render()
           at BrailView_DetailByKey.$Run$closure$5.Invoke(TextWriter
        OutputStream)
           at
        CompilerGenerated.__DetailByKey$callable0$10_9__.Call(Object[]
        args)
           at
        
Castle.MonoRail.Views.Brail.BrailViewComponentContext.RenderSection(String
        sectionName, TextWriter writer)
           at
        Castle.MonoRail.Framework.ViewComponent.RenderSection(String
        sectionName, TextWriter writer)
           at
        Shop.Web.Site.MVC.Components.TableComponent.getRenderedSection(Object
        element)
           at
        Shop.Web.Site.MVC.Components.TableComponent.<Render>b__0(Object
        e)
           at
        System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
           at System.Linq.Enumerable.Count[TSource](IEnumerable`1
        source)
           at
        ProjectBase.Utils.CollectionExtensions.IsEmpty[T](IEnumerable`1
        list)
           at
        ProjectBase.Utils.CollectionExtensions.IsNullOrEmpty[T](IEnumerable`1
        list)
           at
        ProjectBase.Utils.CollectionExtensions.Split[T](IEnumerable`1 list,
        Int32 numberElementsPerList, Boolean padWithDefault)
           at Shop.Web.Site.MVC.Components.TableComponent.Render()
           at BrailView_DetailByKey.Run()
           at
        Castle.MonoRail.Views.Brail.BooViewEngine.RenderView(String
        templateName, BrailBase view)

        but it is also not the view's fault. Sometimes it renders
        sometimes it doesn't. And this view code worked very stable
        in the past. I am not using threading anywhere near this
        code, so I am a bit unsure of how to proceed.
        The logs are full of this exception and the service is
        unstable, so I am under a bit of pressure...

        Any help would be greatly appreciated...

        Jan


        2010/4/1 Krzysztof Koźmic <[email protected]
        <mailto:[email protected]>>

            the only thing, from the top of my head, that comes to
            mind would be
            that it;s a threading issue -one thread returns
            commission steps,
            while an other one adds some more between the calls to
            array.Length
            and array.Copy



            2010/3/31 Jan Limpens <[email protected]
            <mailto:[email protected]>>:
            > never had that one before and I cannot reproduce it,
            so maybe somebody can
            > give me a hint on what to look for...
            >
            > [ArgumentException: Source array was not long enough.
            Check srcIndex and
            > length, and the array's lower bounds.]
            >
            >    System.Array.Copy(Array sourceArray, Int32
            sourceIndex, Array
            > destinationArray, Int32 destinationIndex, Int32
            length, Boolean reliable) +0
            >    System.Collections.Generic.List`1.CopyTo(T[] array,
            Int32 arrayIndex) +25
            >
> Castle.Core.LifecycleStepCollection.GetCommissionSteps() +95
            >
            >
            
Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.ApplyCommissionConcerns(Object
            > instance) +83
            >
            >
            
Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext
            > context) +82
            >
            >
            >
            
Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext
            > context) +47
            >
            >
            
Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext
            > context) +46
> Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext
            > context, Boolean track) +212
            >
> Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext
            > context) +401
> Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler
            handler, Type
            > service, IDictionary additionalArguments) +174
> Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler
            handler, Type
            > service) +47
            >
            >    Castle.MicroKernel.DefaultKernel.get_Item(Type
            service) +245
            >    Castle.MicroKernel.DefaultKernel.Resolve(Type
            service) +118
            >
            >
            
Castle.MonoRail.WindsorExtension.WindsorControllerFactory.CreateController(Type
            > controllerType) +46
            >
            >
            >
            
Castle.MonoRail.WindsorExtension.WindsorControllerFactory.CreateController(String
            > area, String controller) +301
            >
            >
            
Castle.MonoRail.Framework.MonoRailHttpHandlerFactory.GetHandler(HttpContext
            > context, String requestType, String url, String
            pathTranslated) +691
            >
            >
            > [MonoRailException: Error creating controller Css]
            >
            >
            
Castle.MonoRail.Framework.MonoRailHttpHandlerFactory.GetHandler(HttpContext
            > context, String requestType, String url, String
            pathTranslated) +1077
> System.Web.HttpApplication.MapHttpHandler(HttpContext
            context, String
            > requestType, VirtualPath path, String pathTranslated,
            Boolean useAppConfig)
            > +193
            >
            >
            >
            
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
            > +93
> System.Web.HttpApplication.ExecuteStep(IExecutionStep
            step, Boolean&amp;
            > completedSynchronously) +155
            >
            >
            >
            > --
            > Jan
            >
            > --
            > You received this message because you are subscribed
            to the Google Groups
            > "Castle Project Users" group.
            > To post to this group, send email to
            [email protected]
            <mailto:[email protected]>.
            > To unsubscribe from this group, send email to
            > [email protected]
            <mailto:castle-project-users%[email protected]>.
            > For more options, visit this group at
            > http://groups.google.com/group/castle-project-users?hl=en.
            >

            --
            You received this message because you are subscribed to
            the Google Groups "Castle Project Users" group.
            To post to this group, send email to
            [email protected]
            <mailto:[email protected]>.
            To unsubscribe from this group, send email to
            [email protected]
            <mailto:castle-project-users%[email protected]>.
            For more options, visit this group at
            http://groups.google.com/group/castle-project-users?hl=en.




-- Jan -- You received this message because you are subscribed to the
        Google Groups "Castle Project Users" group.
        To post to this group, send email to
        [email protected]
        <mailto:[email protected]>.
        To unsubscribe from this group, send email to
        [email protected]
        <mailto:[email protected]>.
        For more options, visit this group at
        http://groups.google.com/group/castle-project-users?hl=en.

-- You received this message because you are subscribed to the
        Google Groups "Castle Project Users" group.
        To post to this group, send email to
        [email protected]
        <mailto:[email protected]>.
        To unsubscribe from this group, send email to
        [email protected]
        <mailto:castle-project-users%[email protected]>.
        For more options, visit this group at
        http://groups.google.com/group/castle-project-users?hl=en.




-- Jan -- You received this message because you are subscribed to the
    Google Groups "Castle Project Users" group.
    To post to this group, send email to
    [email protected]
    <mailto:[email protected]>.
    To unsubscribe from this group, send email to
    [email protected]
    <mailto:[email protected]>.
    For more options, visit this group at
    http://groups.google.com/group/castle-project-users?hl=en.

-- You received this message because you are subscribed to the Google
    Groups "Castle Project Users" group.
    To post to this group, send email to
    [email protected]
    <mailto:[email protected]>.
    To unsubscribe from this group, send email to
    [email protected]
    <mailto:castle-project-users%[email protected]>.
    For more options, visit this group at
    http://groups.google.com/group/castle-project-users?hl=en.




--
Jan
--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "Castle 
Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.

Reply via email to