Can't create component 'somethingcontroller' as it has dependencies to be satisfied.

1,977 views
Skip to first unread message

LuvSam

unread,
Aug 26, 2009, 6:02:15 PM8/26/09
to S#arp Architecture
Hello,

I'm trying to make a custom repository, and i followed the tutorial on
the sharp architecture wiki site before and it worked. unfortunately
when i started applying that to my project i got the following error.

Can't create component 'Myapp.web.controllers.logincontroller' as it
has dependencies to be satisfied.
MyApp.web.controllers.logincontroller is waiting for the following
dependencies:

Services:
- MyApp.Core.DataInterfaces.IUserRepository which was not registered.

can anybody please help

thanx in advance.

Nick Peeples

unread,
Aug 27, 2009, 11:37:21 AM8/27/09
to S#arp Architecture
Did you build the app using the sharparch template?

I would start tracing through your global.asax.cs first, paying
attention to hopefully where you call the sharparch designed
ComponentRegistrar.AddComponentsTo.

Then look at ComponentRegistrar.AddComponentsTo (if you set that up).
Basically, it sounds like your IoC container is struggling to resolve
it's service dependencies.

- Nick

kebin

unread,
Aug 27, 2009, 11:41:01 AM8/27/09
to S#arp Architecture
Seems like your IUserRepository is in the right place to be picked up
during component registration. Is its implementation at
YourProject.Data?
Message has been deleted

LuvSam

unread,
Aug 28, 2009, 4:15:36 PM8/28/09
to S#arp Architecture
anybody ? any suggestions plz .. i still have the same problem..

On Aug 28, 1:33 am, Ahmad Alsmair <alsm...@gmail.com> wrote:
> thank you guys for your kind interest in solving my problem
>
> yes i defined the IUserRepository interface in the core project, then
> implemented it in teh data project of the sharp architecture template
>
> i really didnt change anything in the default componentregistrar template
> code or in the global.asax and i have done the same scenario described in
> the tutorial of the northwind sample. maybe i am missing out on some extra
> settings done in the northwind application that are not provided by default
> in sharp architecture template?

Nick Peeples

unread,
Aug 28, 2009, 4:48:51 PM8/28/09
to S#arp Architecture
I noticed in your initial post, you have "Myapp" and "MyApp" both. I'm
pretty sure namespaces are case-sensitive, it's possible that you are
confusing things?

- Nick

LuvSam

unread,
Aug 28, 2009, 7:41:29 PM8/28/09
to S#arp Architecture
actually i used the "MyApp" prefix to replace my actual project's name
in this post.. and there's no way the original namespaces are confused
in the project cuz i used the S#arp archi. template to create the
solution. .

kebin

unread,
Aug 29, 2009, 2:17:31 AM8/29/09
to S#arp Architecture
Try to derive your repository from one of the provided interfaces like
INHibernateRepositoryWithTypedId<Customer, string> and your
implementation is deriving from implementation such as
NHibernateRepositoryWithTypedId<Customer, string>, IYourRepository.

- kebin

LuvSam

unread,
Aug 29, 2009, 6:47:46 AM8/29/09
to S#arp Architecture
I tired your suggestion Kebin, implemented
INhibernateRepositoryWithTypeId<User, int> and derived the
implementation from NHibernateRepositoryWithTypeId<User,int> still
getting the same error :

Can't create component 'app.web.controllers.security.userscontroller'
as it has dependencies to be satisfied.
app.web.controllers.security.userscontroller is waiting for the
following dependencies:

Services:
- app.ApplicationServices.IUserRepository which was not registered.

i really have no idea why this is happening. I hoped sharp Arch will
make my life easier...

thnx

Kyle Baley

unread,
Aug 29, 2009, 9:26:32 AM8/29/09
to sharp-arc...@googlegroups.com
The ComponentRegistrar is where I'd start looking. Step through it (which will be cumbersome because it's called in the global.asax.cs) and after the components are all registered, take a look at the container and see what's included in it.

That said, there's a namespace issue somewhere. Your controller is looking for an IUserRepository from ApplicationServices, not Domain. If I recall, nothing from ApplicationServices is added to the container by default. Try deleting the IUserRepository from ApplicationServices and have your controller take the dependency from the IUserRepository in Domain.

LuvSam

unread,
Aug 29, 2009, 2:04:25 PM8/29/09
to S#arp Architecture
Hi Kyle,
i moved the IUserRepository to app.Data but the error didnt go .. so i
looked into the container after it has been filled and found that it
contains the following types:

{app.Web.Controllers.HomeController}
{app.Web.Controllers.Security.UsersController}
{SharpArch.Core.PersistenceSupport.IEntityDuplicateChecker}
{SharpArch.Core.PersistenceSupport.IRepository`1[T]}
{SharpArch.Core.PersistenceSupport.NHibernate.INHibernateRepository`1
[T]}
{SharpArch.Core.PersistenceSupport.IRepositoryWithTypedId`2[T,IdT]}
{SharpArch.Core.PersistenceSupport.NHibernate.INHibernateRepositoryWithTypedId`2
[T,IdT]}
{app.Data.NHibernateMaps.Conventions.ReferenceConvention}
{app.Data.NHibernateMaps.AutoPersistenceModelGenerator}
{app.Data.NHibernateMaps.Conventions.PrimaryKeyConvention}
{app.Data.NHibernateMaps.Conventions.HasManyConvention}
{app.Data.NHibernateMaps.Conventions.TableNameConvention}
{SharpArch.Core.CommonValidator.IValidator}

so i decided to register it manually with the following line of code
in the componentregistrar's static method "AddComponentsTo"

container.AddComponent("userrepository",
typeof(IUserRepository), typeof( UserRepository));

that fixed it !

thank you all guys for your help, really appreciated.


On Aug 29, 4:26 pm, Kyle Baley <k...@baley.org> wrote:
> The ComponentRegistrar is where I'd start looking. Step through it (which
> will be cumbersome because it's called in the global.asax.cs) and after the
> components are all registered, take a look at the container and see what's
> included in it.
>
> That said, there's a namespace issue somewhere. Your controller is looking
> for an IUserRepository from ApplicationServices, not Domain. If I recall,
> nothing from ApplicationServices is added to the container by default. Try
> deleting the IUserRepository from ApplicationServices and have your
> controller take the dependency from the IUserRepository in Domain.
>
Reply all
Reply to author
Forward
0 new messages