Unable to cast object of type 'ASP.global_asax' to type 'Castle.Windsor.IContainerAccessor'. Exception,

965 views
Skip to first unread message

Bobby Fallaha

unread,
May 18, 2010, 2:12:29 PM5/18/10
to Castle Project Users
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 castle-pro...@googlegroups.com.
To unsubscribe from this group, send email to castle-project-u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.

Mauricio Scheffer

unread,
May 18, 2010, 3:02:23 PM5/18/10
to Castle Project Users
Check if your HttpApplication (in global.asax.cs) implements
IContainerAccessor

Bobby Fallaha

unread,
May 18, 2010, 3:26:20 PM5/18/10
to Castle Project Users
Thanks Mauricio, that fixed it...

On May 18, 2:02 pm, Mauricio Scheffer <mauricioschef...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages