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

Ask A Question

Stats

  • Questions 113k
  • Answers 113k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer An ObservableCollection is not a view on an underlying collection… May 11, 2026 at 10:00 pm
  • Editorial Team
    Editorial Team added an answer It is likely that if you use the profiler and… May 11, 2026 at 10:00 pm
  • Editorial Team
    Editorial Team added an answer offset = direction * longitude * 24 / 360 where… May 11, 2026 at 10:00 pm

Related Questions

I am getting an 'Access to the path is denied error message when running
I am getting an 'access is denied' error when I attempt to delete a
I am getting an undefined index on my config page and it reads: Notice
I am getting an error when trying to use the resource route helper functions
I am getting an error when the UnityContainer.Resolve method runs which states... An unhandled

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.