Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5985225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:29:56+00:00 2026-05-22T22:29:56+00:00

Edit: The below information was the symptom that led me to the following tests.

  • 0

Edit: The below information was the symptom that led me to the following tests. I downloaded, compiled, and ran all the tests for NHibernate under Release mode. They all work. I fired up NH Profiler and looked at the difference between the logs in Debug and Release. Release didn’t appear to be executing any SQL besides the transaction open and close statements. Verified that fact with SQL profiler.

So NHibernate can connect to the database and execute transaction begin / end statements ok, and I can connect and execute arbitrary SQL via the normal ADO methods as well, but NHibernate can NOT execute any other SQL under Release mode.

My session is opened and closed at the beginning and end of each request via an HttpModule, which uses a SessionFactory singleton inside a UnitOfWork implementation which is cached in HttpContext by Structuremap.

It all works wonderfully under Debug.

Also, changing my calling code to make sure that the first called NHibernate method is a Load returns this to me:

Unable to locate persister: Domain.Model.User

Edit 2:
Here’s the stack trace…

[HibernateException: Unable to locate persister: STEP.Domain.Model.User]
   NHibernate.Event.Default.DefaultLoadEventListener.OnLoad(LoadEvent event, LoadType loadType) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Event\Default\DefaultLoadEventListener.cs:58
   NHibernate.Impl.SessionImpl.FireLoad(LoadEvent event, LoadType loadType) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\SessionImpl.cs:2466
   NHibernate.Impl.SessionImpl.Load(String entityName, Object id) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\SessionImpl.cs:1213
   NHibernate.Impl.SessionImpl.Load(Type entityClass, Object id) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\SessionImpl.cs:1242
   NHibernate.Impl.SessionImpl.Load(Object id) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\SessionImpl.cs:1166
   STEP.Persistence.Repositories.RepositoryWithTypedId`2.Load(TId id) in C:\Projects\STEP Handbook Dev\src\STEP.Persistence\Repositories\Repository.cs:80
   STEP.Website.Providers.STEPNHibernateMembershipProvider.ValidateUser(String username, String password) in C:\Projects\STEP Handbook Dev\src\STEP.Website\Providers\STEPNHibernateMembershipProvider.cs:490
   STEP.Website.Controllers.AccountController.LogOn(LogOnViewModel model, String returnUrl) in C:\Projects\STEP Handbook Dev\src\STEP.Website\Controllers\AccountController.cs:759
   lambda_method(Closure , ControllerBase , Object[] ) +179
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +264
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +39
   System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +129
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +785306
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +785306
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +785306
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +785306
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +314
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +785360
   System.Web.Mvc.Controller.ExecuteCore() +159
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +54
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +453
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +371

And the code that triggers this is just a simple Session.Load(id) call to NHibernate.

Original:

When running NHibernate 3.1, I am getting an “Index was out of range” exception, but only when compiling in Release mode. I’m calling NHibernate here:

var results = Session.Query<User>.Where(predicate);

Then right below this, I am checking to see how many get returned (As this is actually my FindOne() method in my repository, and I need to make sure I only get one back). So I am calling results.Count(), which is triggering the NHibernate query to execute.

My stack trace shows that this is happening in NhQueryprovider.ExecuteQuery at the last line of the method (Which is “return results[0]”). The only thing I can get from this is that apparently NHibernate is getting an empty list back there (It shouldn’t there should be at least one result returned here…) which is causing this.

This COULD be a bug in the NHibernate.Linq stuff that hasn’t been caught yet, as I believe that just went native to Nhibernate in 3.x… Anyone else see this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:29:57+00:00Added an answer on May 22, 2026 at 10:29 pm

    I figured it out. The issue, as pointed to by the error about persisters, was that NHibernate was not getting any mapping files in Release mode.

    The reason turned out to be because when I was configuring Fluent NHibernate with a PersistenceModel, I was calling PersistenceModel.AddMappingsFromThisAssembly() instead of PersistenceModel.AddMappingsFromAssembly(Assembly). While the former worked fine in Debug mode, in Release mode it apparently does not.

    Changing my initialization code to use the latter fixed all my issues. The original issue, with the out of range exception, seems to be a failing on NHibernate.LINQ’s part to account for this exceptional state.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Read the edit below for more information. I have some code below that I
Edit: original question below, but I revise it now that I have some code
EDIT: See my answer below--> I am wanting to have a view that when
EDIT: In case the question below looks a bit 'extensive', the summary is that
**EDIT: There are several options below that would work. Please vote/comment according to your
EDIT -- Answered below, missed the angled braces. Thanks all. I have been attempting
Please note the Edit below for a lot more information, and a possible solution
I am looking for Datagrid that retrieves information from database along with below feature.
[Edit 2: More information and debugging in answer below...] I'm writing a python script
PLEASE SEE THE EDIT BELOW, THE REPORT SEEMS TO USE CACHED DATA? I cant

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.