NHibernate Facility Problem

449 views
Skip to first unread message

digitalbricklayer

unread,
Apr 8, 2011, 12:05:23 PM4/8/11
to Castle Project Users
I've been stuck on the following problem for the last few days and in
desperation I am posting it here. I have successfully used NHibernate
Facility in a simple console app to read and write to a database using
Castle Windsor to get hold of a session manager instance and create a
session.

I installed the facility libraries using NuGet and the same with
Fluent NHibernate. The same versions work fine in the console
application.

The DLL versions are:
Castle.Core.dll: 2.5.2.0
Castle.Facilities.NHibernateIntegration.dll: 1.1.0.11
Castle.Facilities.Synchronize.dll: 2.5.1.2127
Castle.Facilities.Transaction.dll: 2.5.0.52
Castle.Windsor.dll: 2.5.1.2127
FluentNHibernate.dll: 1.2.0.712
NHibernate.dll: 3.1.0.4000

When I try the exact same thing with an ASP.NET MVC 3 application
injecting the session manager into a controller things fail with the
following error (on the SessionManager.OpenSession() call.

Method 'IsReadOnly' in type
'Castle.Facilities.NHibernateIntegration.SessionDelegate' from
assembly 'Castle.Facilities.NHibernateIntegration, Version=1.1.0.0,
Culture=neutral, PublicKeyToken=407dd0808d44fbdc' does not have an
implementation.

The call stack looks like this:

[TypeLoadException: Method 'IsReadOnly' in type
'Castle.Facilities.NHibernateIntegration.SessionDelegate' from
assembly 'Castle.Facilities.NHibernateIntegration, Version=1.1.0.0,
Culture=neutral, PublicKeyToken=407dd0808d44fbdc' does not have an
implementation.]

Castle.Facilities.NHibernateIntegration.DefaultSessionManager.OpenSession(String
alias) +0

Castle.Facilities.NHibernateIntegration.DefaultSessionManager.OpenSession()
+37
CastleFacilitiesMvcTest.Controllers.HomeController.Index() in c:
\workspace\CastleFacilitiesMvcTest\CastleFacilitiesMvcTest\Controllers
\HomeController.cs:23
lambda_method(Closure , ControllerBase , Object[] ) +96
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase
controller, Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext
controllerContext, IDictionary`2 parameters) +208

System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext
controllerContext, ActionDescriptor actionDescriptor, IDictionary`2
parameters) +27

System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12()
+55

System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter
filter, ActionExecutingContext preContext, Func`1 continuation) +263

System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14()
+19

System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext
controllerContext, IList`1 filters, ActionDescriptor actionDescriptor,
IDictionary`2 parameters) +191

System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext
controllerContext, String actionName) +343
System.Web.Mvc.Controller.ExecuteCore() +116
System.Web.Mvc.ControllerBase.Execute(RequestContext
requestContext) +97

System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext
requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
+21

System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult
_) +12
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f)
+7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action
action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult
asyncResult) +60

System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult
result) +9

System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+8841105
System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously) +184


If anybody has any ideas I'd love to hear them because I'm all out of
them.

Maximilian Raditya

unread,
Apr 8, 2011, 6:00:16 PM4/8/11
to castle-pro...@googlegroups.com
On Fri, Apr 8, 2011 at 11:05 PM, digitalbricklayer <jhu...@openxtra.co.uk> wrote:
Castle.Facilities.NHibernateIntegration.dll: 1.1.0.11
NHibernate.dll: 3.1.0.4000


I think you should update the NHibernate Facility library to the latest one. It's 2.0 RC, and the assembly version is 1.1.0.39. See here: http://groups.google.com/group/castle-project-users/t/ac90148a8d4c8477.
 
 
 

--
Regards,

Maximilian Haru Raditya

Jack Hughes

unread,
Apr 11, 2011, 4:44:35 AM4/11/11
to castle-pro...@googlegroups.com

Thanks Maximilian updating to 2.0RC has solved the problem.

--
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.

Dan B

unread,
Jun 9, 2011, 4:40:08 AM6/9/11
to Castle Project Users
I had the same problem using it in Unit Tests.

I upgraded to RC 2.0 and now I'm getting this error:

System.TypeLoadException : Method 'QueryOver' in type
'Castle.Facilities.NHibernateIntegration.SessionDelegate' from
assembly 'Castle.Facilities.NHibernateIntegration, Version=1.1.0.0,
Culture=neutral, PublicKeyToken=407dd0808d44fbdc' does not have an
implementation.

Any ideas?

On Apr 11, 9:44 am, Jack Hughes <JHug...@openxtra.co.uk> wrote:
> Thanks Maximilian updating to 2.0RC has solved the problem.
>
> From: castle-pro...@googlegroups.com [mailto:castle-pro...@googlegroups.com] On Behalf Of Maximilian Raditya
> Sent: 08 April 2011 23:00
> To: castle-pro...@googlegroups.com
> Subject: Re: NHibernate Facility Problem
>
> On Fri, Apr 8, 2011 at 11:05 PM, digitalbricklayer <jhug...@openxtra.co.uk<mailto:jhug...@openxtra.co.uk>> wrote:
> Castle.Facilities.NHibernateIntegration.dll: 1.1.0.11
> NHibernate.dll: 3.1.0.4000<tel:3.1.0.4000>

Maximilian Raditya

unread,
Jun 9, 2011, 5:49:53 AM6/9/11
to castle-pro...@googlegroups.com
Hmm..., that's weird.
 
Have you checked your project refer to the correct NH Integration Facility version? It should be 1.1.0.39, not 1.1.0.0.
 
And also, what NH version do you use? It should be NH 3.1 GA.
 
 
 
 
--
Regards,

Maximilian Haru Raditya


 

Dan B

unread,
Jun 9, 2011, 6:03:47 AM6/9/11
to Castle Project Users
I was trying to use NHibernate 3.2.0.2001 - I just added in the
missing methods and it works great, thanks.

Maximilian Raditya

unread,
Jun 9, 2011, 6:16:04 AM6/9/11
to castle-pro...@googlegroups.com
IC.
 
AFAIK, there are several API changes in ISession and IStatelessSession between NH 3.0 GA and 3.1 GA, and between 3.1 GA and 3.2 BETA. The issue you encountered seems to be related to the changes introduced in NH 3.2 BETA.

Maximilian Raditya

unread,
Feb 26, 2013, 4:11:53 AM2/26/13
to Castle Project Users (Group)
Well, I finally solve it by forking and upgrading it by myself... :D
See my own fork of it here:

https://github.com/mahara/Castle.Facilities.NHibernateIntegration
 
I just upgraded it to use the latest the Castle.Core and Castle.Windsor 3.2.0. It also uses NHibernate 3.3.2 GA. And it supports .NET 3.5, 4.0, and 4.5 using the latest Castle bits.
All previous tests pass. But I guarantee nothing, nor it's something official.
Try it yourself whether it'd work for you. So far, it works just fine for me.
 
But if, strictly speaking, about how to solve it by yourself, there are some APIs changes in NHibernate between version 3.0.x and 3.2.x IIRC. Just see my commits for such details there.
I even completely forgot what did I do when upgrading it to use the latest NHibernate version... LOL
 
 


On Tue, Feb 19, 2013 at 9:59 PM, Mauro Cecili <mauro....@gmail.com> wrote:
I ave your same problem?
How do yo solved it?
In my references i use NHibernate 3.2.0.2001 and astle.Facilities.NHibernateIntegration 1.1.0.39
but where i add the last one in visual studio in object ispector version value is 1.1.0.0

When i run i have an error : 1.1.0.39 not found
if i force binding in web.config to 1.1.0.0
i have an error when Nh Open Session: 'QueryOver' method 'Castle.Facilities.NHibernateIntegration.SessionDelegate' not implemented

Any suggest?

Il giorno giovedì 9 giugno 2011 12:03:47 UTC+2, Dan B ha scritto:
I was trying to use NHibernate 3.2.0.2001 - I just added in the
missing methods and it works great, thanks.

 
 

Samuel Pereira

unread,
Jun 24, 2014, 10:50:53 PM6/24/14
to castle-pro...@googlegroups.com
Hi Maximilian,

I have many projects with Castla/Nhibernate 3.1 . So I need to nhibernate 3.3, what you suggest?

Do you know if is there a new way of work with castle 3.* and nhibernate 3.3*?

I appreciate any help!!


--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to castle-project-u...@googlegroups.com.

To post to this group, send email to castle-pro...@googlegroups.com.



--
Regards,

Samuel Pereira
Senior Systems Analyst

Maximilian Haru Raditya

unread,
Jun 27, 2014, 5:43:27 AM6/27/14
to Castle Project Users (Group)
Whoa... this is an old thread! :D

For me, it's better to stay up-to-date to minimize the upgrade cost. But then, it really depends on your needs and circumstances. You need to assess them yourself whether such upgrade is a viable option.

The best way to upgrade them is by firstly reading their release notes to see whether there are breaking changes introduced by newer versions of these libraries that could affect your projects/apps. After that, test the waters to see whether it works by upgrading them one by one and making necessary adjustments based on any feedback you got while upgrading them. Also, it would be easier and better if you had unit/integration/automated tests to run for testing the upgrades.

Good luck! :)



Samuel Pereira

unread,
Jun 27, 2014, 2:41:52 PM6/27/14
to castle-pro...@googlegroups.com
Thank you Maximilian!

I have unit/integration/automated. That makes it a bit easier. 
In all project the session is provided by sessionMananger(NHibernateIntegration) and I use too "Transaction facility". Do you have some suggestion for continue with transaction and some strategy closer this for using NHibernate 3.3*?

Martijn Boland

unread,
Jun 27, 2014, 4:15:57 PM6/27/14
to castle-pro...@googlegroups.com
A few months ago I was in the same situation. Tried to upgrade to the newer Castle.Facilities.NHibernate facility, but I found I had quite a lot of old infrastructural code depending on the old Castle libs that wasn't compatible (by far) with the newer libs.

Found Maximilian's fork (https://github.com/mahara/Castle.Facilities.NHibernateIntegration), build that locally and now I use Castle.Facilities.AutoTx.dll, Castle.Facilities.NHibernateIntegration.dll, Castle.Services.Transaction.dll from his fork together with the latest and greatest NHibernate and Castle.Core libs from NuGet. 

Works like a charm and almost no code changes were required, so I think that's the way to go. In https://github.com/martijnboland/cuyahoga-1/tree/master/lib you can find the assemblies if you don't like to fork and build yourself.

Samuel Pereira

unread,
Jun 30, 2014, 6:58:24 AM6/30/14
to castle-pro...@googlegroups.com
I guess that I going to this way. Thank you guys.

jigar sheth

unread,
Sep 29, 2014, 9:57:45 PM9/29/14
to castle-pro...@googlegroups.com

I downloaded the source for NHibernateIntegration from (https://github.com/mahara/Castle.Facilities.NHibernateIntegration)

I added reference for Castle.Core (3.3.0.0), Castle.Services.Transaction (3.3.0.0), Castle.Windsor (3.3.0.0), NHibernate (4.0.0.4000) and I built the application to generate the Castle.Facilities.NHibernateIntegration.dll

But after the upgrading NHibernateIntegration.dll in my application I am getting the following error,

An ISessionFactory component was not mapped for the specified alias: AliasName

To unsubscribe from this group and stop receiving emails from it, send an email to castle-project-users+unsub...@googlegroups.com.

To post to this group, send email to castle-pro...@googlegroups.com.
Visit this group at http://groups.google.com/group/castle-project-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Regards,

Samuel Pereira
Senior Systems Analyst

--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to castle-project-users+unsub...@googlegroups.com.

To post to this group, send email to castle-pro...@googlegroups.com.



--
Regards,

Maximilian Haru Raditya

--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to castle-project-users+unsub...@googlegroups.com.

To post to this group, send email to castle-pro...@googlegroups.com.



--
Regards,

Samuel Pereira
Senior Systems Analyst

--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to castle-project-users+unsub...@googlegroups.com.

To post to this group, send email to castle-pro...@googlegroups.com.
Visit this group at http://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to castle-project-users+unsub...@googlegroups.com.

To post to this group, send email to castle-pro...@googlegroups.com.
Visit this group at http://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages