I am attempting to auto register all controllers in my MVC project but
I'm having issues getting the correct service type chosen. Here is the
code I'm using:
container
.Register(
assembliesToAutoRegisterFrom
.Select(a =>
AllTypes
.FromAssembly(a)
.BasedOn<IController>()
.WithService.Self()
.Configure(c =>
c.LifeStyle.Transient))
.ToArray());
A few things: assembliesToAutoRegisterFrom is just an IEnumerable of
Assembly. According to the docs, I don't think I need
".WithService.Self()" either as this should be the default.
Here is what I'm observing. One of my test assemblies has
TestController : SessionController. SessionController inherit from
Mvc.Controller which implements IController. If I break into the
debugger after the register call, I see that the controller got
registered, but it shows the service type as IController and calls to
Resolve<TestController> fail.
If I put a breakpoint inside the call to .Configure on the lambda
body, I can see that c.Implementation is TestController and c.Service
is TestController, too (ie, it's correct).
What am I doing wrong here?
--
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.