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 195091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:39:04+00:00 2026-05-11T16:39:04+00:00

I am getting an ArgumentOutOfRangeException on parameter index whenever I try to instantiate a

  • 0

I am getting an “ArgumentOutOfRangeException” on parameter index whenever I try to instantiate a session factory in nHibernate. The error comes from a procedure deep in the bowels of nHibernate. I can post the stack-trace of the error if that would help.

This is on a fresh project with a pretty simple three tier architecture. The data layer maps the nHibernate classes to simple interfaces which are implemented by the business layer. Currently there is only one interface set and mapping file being used by nHibernate. Hopefully my issue is easy to spot.

Here is the function where I build the sessionFactory.

  Private Shared Function SessionFactory() As ISessionFactory
        If _sessionFactory Is Nothing Then
            Dim config As New NHibernate.Cfg.Configuration
            config.Configure()
            config.AddClass(GetType(ICompanyProperty))
            _sessionFactory = config.BuildSessionFactory            
        End If
        Return _sessionFactory
    End Function

Here is my hibernate.cfg.xml

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory>
    <property name="connection.provider">
      NHibernate.Connection.DriverConnectionProvider     
    </property>
    <property name="dialect">
      NHibernate.Dialect.MsSql2005Dialect
    </property>
    <property name="connection.driver_class">
      NHibernate.Driver.SqlClientDriver
    </property>
    <property name="connection.connection_string">
      Data Source=dataserver.domain.ad;Initial Catalog=LABs;Integrated Security=SSPI
    </property>
  </session-factory>
</hibernate-configuration>

And the mapping file of the interface I am mapping.

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Sample.Data" namespace="Sample.Data">
  <class name="ICompanyProperty" table="CompanyProperty">
    <id name="CompanyPropertyID" column="CompanyPropertyID">
      <generator class="native" />
    </id>    
    <discriminator column="PropertyType" type="String" />
    <property name="CompanyID" />
    <property name="PropertyName" />    
    <subclass discriminator-value="SQL" name="ISQLLookupCompanyProperty">
      <property name="TableName" />      
      <property name="KeyField" />
      <property name="ValueField" />
      <property name="ConnectionString" />
    </subclass>
    <subclass discriminator-value="LIST" name="ILookupCompanyProperty" />    
  </class>
</hibernate-mapping>

And the interfaces

Public Interface ICompanyProperty
    Property CompanyPropertyID() As Integer
    Property PropertyName() As String
    Property CompanyID() As Integer
    Property PropertyType() As String
End Interface

Public Interface ILookupCompanyProperty
    Inherits ICompanyProperty
End Interface

Public Interface ISQLLookupCompanyProperty
    Inherits ILookupCompanyProperty

    Property TableName() As String
    Property KeyField() As String
    Property ValueField() As String
    Property ConnectionString() As String
End Interface

Thank you!

Edit: The stacktrace was requested. here it is from my call of build session factory to the error.

at System.Collections.ArrayList.get_Item(Int32 index)
at NHibernate.SqlCommand.InFragment.ToFragmentString()
at NHibernate.Persister.Entity.SingleTableEntityPersister.DiscriminatorFilterFragment(String alias)
at NHibernate.Persister.Entity.SingleTableEntityPersister.FilterFragment(String alias)
at NHibernate.Persister.Entity.AbstractEntityPersister.FilterFragment(String alias, IDictionary`2 enabledFilters)
at NHibernate.Loader.Entity.EntityJoinWalker..ctor(IOuterJoinLoadable persister, String[] uniqueKey, Int32 batchSize, LockMode lockMode, ISessionFactoryImplementor factory, IDictionary`2 enabledFilters)
at NHibernate.Loader.Entity.EntityLoader..ctor(IOuterJoinLoadable persister, String[] uniqueKey, IType uniqueKeyType, Int32 batchSize, LockMode lockMode, ISessionFactoryImplementor factory, IDictionary`2 enabledFilters)
at NHibernate.Loader.Entity.EntityLoader..ctor(IOuterJoinLoadable persister, Int32 batchSize, LockMode lockMode, ISessionFactoryImplementor factory, IDictionary`2 enabledFilters)
at NHibernate.Loader.Entity.EntityLoader..ctor(IOuterJoinLoadable persister, LockMode lockMode, ISessionFactoryImplementor factory, IDictionary`2 enabledFilters)
at NHibernate.Loader.Entity.BatchingEntityLoader.CreateBatchingEntityLoader(IOuterJoinLoadable persister, Int32 maxBatchSize, LockMode lockMode, ISessionFactoryImplementor factory, IDictionary`2 enabledFilters)
at NHibernate.Persister.Entity.AbstractEntityPersister.CreateEntityLoader(LockMode lockMode, IDictionary`2 enabledFilters)
at NHibernate.Persister.Entity.AbstractEntityPersister.CreateEntityLoader(LockMode lockMode)
at NHibernate.Persister.Entity.AbstractEntityPersister.CreateLoaders()
at NHibernate.Persister.Entity.AbstractEntityPersister.PostInstantiate()
at NHibernate.Persister.Entity.SingleTableEntityPersister.PostInstantiate()
at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners)
at NHibernate.Cfg.Configuration.BuildSessionFactory()

Edit2: When I remove the discriminator I no longer get this error. Am I not doing that right?

Edit 3: When I download the source code for nHibernate, build it on my own, link to it’s debug output and run it, I get a completely different error about ProxyFactoryFactory not being configured.

  • 1 1 Answer
  • 1 View
  • 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-11T16:39:05+00:00Added an answer on May 11, 2026 at 4:39 pm

    I think you need to tell NHibernate what concrete classes to use. To do that using interfaces, you need to nest the subclass mapping:

    <subclass discriminator-value="SQL" name="ISQLLookupCompanyProperty">
      <subclass discriminator-value="SQL" name="SQLLookupCompanyProperty>
          <property name="TableName" />      
          <property name="KeyField" />
          <property name="ValueField" />
          <property name="ConnectionString" />
      </subclass>
    </subclass>
    <subclass discriminator-value="LIST" name="ILookupCompanyProperty">
        <subclass discriminator-value="LIST" name="LookupCompanyProperty" />
    </subclass>
    

    I found this solution in a blog entry.

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

Sidebar

Related Questions

Getting some zlib error in the middle of cloning big (4 GB) repo from
The error I'm getting is System.ArgumentOutOfRangeException was unhandled. It asks that month be between
When I am deleting a row from grid view I am getting following error.
Getting an Undefined Offset error here -- apparently from the $newval array. Note that
Getting the subdomain from a URL sounds easy at first. http://www.domain.example Scan for the
Getting started with NHibernate How can I generate identity fields in nHibernate using Hilo
Getting the above error in following code. How to rectify it. Thanks. Please look
Getting this error: 2009-09-03 12:44:02.307 xcodebuild[307:10b] warning: compiler 'com.apple.compilers.llvm.clang.1_0.analyzer' is based on missing compiler
Getting a rendering error for this form: 'NoneType' object has no attribute 'widget' http://dpaste.com/88585/
Getting a 'marshal data too short' error when trying to install the mysql gem

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.