Implementation asp identity with #Sharp. Registration of ISession.

67 views
Skip to first unread message

Javier Romero

unread,
May 29, 2015, 11:54:16 AM5/29/15
to sharp-arc...@googlegroups.com
I'm using #Sharp 3.01 and I'm trying to implement Nhibernate Aspnet Identity. 
I have some projects working fine but those use #Sharp 2.x ... 

When I debug the app I got this error message: 


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

'userStore' is waiting for the following dependencies:
- Service 'NHibernate.ISession' which was not registered.



The userStore component is called in the Install method for Identity Installer: 
---------------------------------------------------------------------------
public class IdentityInstaller : IWindsorInstaller
    {
        #region Public Methods and Operators

        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.Register(
                Component.For(typeof(IUserStore<>))
                    .ImplementedBy(typeof(UserStore<>))
                    .Named("userStore")
                    .LifestylePerWebRequest());
            container.Register(
                Component.For(typeof(IRoleStore<>))
                    .ImplementedBy(typeof(RoleStore<>))
                    .Named("roleStore")
                    .LifestylePerWebRequest());
            container.Register(
                Component.For(typeof(UserManager<>))
                    .ImplementedBy(typeof(UserManager<>))
                    .Named("userManager")
                    .LifestylePerWebRequest());
        }

        #endregion
    }

--------------------------------------------------

This kind of error is new for me. Someone please give some advice about this.

Regards

Shatl

unread,
May 29, 2015, 3:12:50 PM5/29/15
to sharp-arc...@googlegroups.com
Hi,
AFAIK ISession is not registered in container by default. I believe you expect it as constructor parameter.

Register it or use NHibernateSession.Current in your store.

Javier Romero

unread,
May 29, 2015, 6:30:38 PM5/29/15
to sharp-arc...@googlegroups.com
Thanks.... 

I've registered the ISession and the problem is gone.
Like this:

container.Register(
    Component.For<ISessionFactory>()
        .UsingFactoryMethod(_ => NHibernateSession.GetDefaultSessionFactory()),
    Component.For<ISession>()
        .UsingFactoryMethod(k => k.Resolve<ISessionFactory>().OpenSession()));

Javier Romero

unread,
Jun 2, 2015, 1:54:10 PM6/2/15
to sharp-arc...@googlegroups.com
It seems that the mapping of the models in the Nhibernate ASP.NET Identity does not work.
Because the test that generates the database schema does not contain the related tables. 

And when I need to query against de Repositories I got this error: 

Interceptor.OnPrepareStatement(SqlString) returned null or empty SqlString.


Maybe someone can help me. 
I need I guide about this.

Seif Attar

unread,
Jun 2, 2015, 8:39:35 PM6/2/15
to sharp-arc...@googlegroups.com
What is the model? are the classes you are trying to map inheriiting from Entity or EntityWithTypedId? more code samples/info would be useful

--
You received this message because you are subscribed to the Google Groups "S#arp Architecture" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sharp-architect...@googlegroups.com.
To post to this group, send email to sharp-arc...@googlegroups.com.
Visit this group at http://groups.google.com/group/sharp-architecture.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages