Check if your HttpApplication (in global.asax.cs) implements IContainerAccessor
On May 18, 3:12 pm, Bobby Fallaha <[email protected]> wrote: > I am getting this error message in my sessionModule class when trying > to fire up the OnBeginRequest event. > > Here is how my code looks like: > > private void OnBeginRequest(object sender, EventArgs e) > { > HttpApplication app = (HttpApplication)sender; > var container = ((IContainerAccessor)app).Container; > > var sessions = > RetrieveAppSessions((ISessionManager)container[typeof(ISessionManager)]); > foreach (var item in sessions) > RegisterSession(app, item.Value, item.Key); > } > > And here is the exception i am receiving: > > Exception Details: System.InvalidCastException: Unable to cast object > of type 'ASP.global_asax' to type 'Castle.Windsor.IContainerAccessor'. > > Source Error: > > Line 37: { > Line 38: HttpApplication app = (HttpApplication)sender; > Line 39: IWindsorContainer container = > ((IContainerAccessor)app).Container; > Line 40: > Line 41: var sessions = > RetrieveAppSessions((ISessionManager)container[typeof(ISessionManager)]); > > Source File: SessionModule.cs Line: 39 > > Stack Trace: > > [InvalidCastException: Unable to cast object of type 'ASP.global_asax' > to type 'Castle.Windsor.IContainerAccessor'.] > SessionModule.OnBeginRequest(Object sender, EventArgs e) in > SessionModule.cs:39 > > System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep > .Execute() > +68 > System.Web.HttpApplication.ExecuteStep(IExecutionStep step, > Boolean& completedSynchronously) +75 > > Version Information: Microsoft .NET Framework Version:2.0.50727.3603; > ASP.NET Version:2.0.50727.3082 > > Any idea? > > thanks > > -- > 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 > athttp://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.
