CpBT + PostSharp + Ninject : No current conversation available. Create a conversation and bind it to the container

83 views
Skip to first unread message

Michael Delva

unread,
Nov 18, 2010, 12:00:42 PM11/18/10
to uNhAddIns
Hello all,

I'd like to use the CpBT pattern, in conjunction with PostSharp and
Ninject.

Here are my bindings for Ninject:

Bind<IConfigurationProvider>()
.To<FluentConfigurationProvider>()
.InSingletonScope();

Bind<ISessionFactoryProvider>()
.To<SessionFactoryProvider>()
.InSingletonScope()
.OnActivation(builder => OutputMessage("Initalizing
database..."));

Bind<ISessionFactory>()
.ToMethod(ctx =>
ctx.Kernel.Get<ISessionFactoryProvider>().GetFactory(null));

Bind<ISessionWrapper>().To<FakeSessionWrapper>();

Bind<IConversationFactory>().To<DefaultConversationFactory>().InSingletonScope();

Bind<IConversationsContainerAccessor>().To<NhConversationsContainerAccessor>().InSingletonScope();

I've put the PersistenceConversational attributes on top of my view-
model.

When I want to open my VM, I have the following exception: No current
conversation available. Create a conversation and bind it to the
container

Is there something I forgot to do?

Thanks in advance

Mike

José F. Romaniello

unread,
Nov 18, 2010, 2:54:26 PM11/18/10
to unha...@googlegroups.com
did you set the current session context in your nhibernate configuration?

<property name="current_session_context_class">
 uNhAddIns.SessionEasier.Conversations.ThreadLocalConversationalSessionContext, uNhAddIns
</property>

2010/11/18 Michael Delva <mic...@emidee.net>

Michael Delva

unread,
Nov 19, 2010, 4:10:04 AM11/19/10
to uNhAddIns
Yes I did.

But I found my mistake. This was a dumb error of my own, which is
fixed now :)



On 18 nov, 20:54, José F. Romaniello <jfromanie...@gmail.com> wrote:
> did you set the current session context in your nhibernate configuration?
>
> <property name="current_session_context_class">
>  uNhAddIns.SessionEasier.Conversations.ThreadLocalConversationalSessionConte xt,
> uNhAddIns
> </property>
>
> 2010/11/18 Michael Delva <mich...@emidee.net>

Gustavo Ringel

unread,
Nov 19, 2010, 4:33:40 AM11/19/10
to unha...@googlegroups.com
I suggest to share it here...People looking for solutions will find it useful later.
And we all tend to forget and repeat the same errors.

Thanks.

Gustavo.

Michael Delva

unread,
Nov 19, 2010, 5:13:21 AM11/19/10
to uNhAddIns
I had just forgotten to put the PersistenceConversationAttribute, in
addition to the PersistenceConversationalAttribute.
Reply all
Reply to author
Forward
0 new messages