Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

FluentNHibernate "Object reference not set to an instance of an object" #18

Closed
wsky opened this Issue · 5 comments

1 participant

@wsky
Owner

fluentnh在mono下,部分情况映射时发生如下异常

Errors and Failures:
[exec] 1) SetUp Error : Cooper.Model.Test.AccountConnectionTest
[exec] SetUp : System.NullReferenceException : Object reference not set to an instance of an object
[exec] at FluentNHibernate.Visitors.DefaultMappingModelVisitor.Visit (FluentNHibernate.MappingModel.ColumnMapping columnMapping) [0x00000] in :0
[exec] at FluentNHibernate.MappingModel.PropertyMapping.AcceptVisitor (IMappingModelVisitor visitor) [0x00000] in :0
[exec] at FluentNHibernate.Visitors.DefaultMappingModelVisitor.Visit (FluentNHibernate.MappingModel.PropertyMapping propertyMapping) [0x00000] in :0
[exec] at FluentNHibernate.MappingModel.MappedMembers.AcceptVisitor (IMappingModelVisitor visitor) [0x00000] in :0
[exec] at FluentNHibernate.MappingModel.ClassBased.ClassMappingBase.AcceptVisitor (IMappingModelVisitor visitor) [0x00000] in :0
[exec] at FluentNHibernate.MappingModel.ClassBased.SubclassMapping.AcceptVisitor (IMappingModelVisitor visitor) [0x00000] in :0
[exec] at FluentNHibernate.Visitors.DefaultMappingModelVisitor.Visit (FluentNHibernate.MappingModel.ClassBased.SubclassMapping subclassMapping) [0x00000] in :0
[exec] at FluentNHibernate.MappingModel.ClassBased.ClassMappingBase.AcceptVisitor (IMappingModelVisitor visitor) [0x00000] in :0
[exec] at FluentNHibernate.MappingModel.ClassBased.ClassMapping.AcceptVisitor (IMappingModelVisitor visitor) [0x00000] in :0
[exec] at FluentNHibernate.Visitors.DefaultMappingModelVisitor.Visit (FluentNHibernate.MappingModel.ClassBased.ClassMapping classMapping) [0x00000] in :0
[exec] at FluentNHibernate.MappingModel.HibernateMapping.AcceptVisitor (IMappingModelVisitor visitor) [0x00000] in :0
[exec] at FluentNHibernate.Visitors.DefaultMappingModelVisitor.b__0 (FluentNHibernate.MappingModel.HibernateMapping x) [0x00000] in :0
[exec] at FluentNHibernate.Utils.CollectionExtensions.EachHibernateMapping [0x00000] in :0
[exec] at FluentNHibernate.Visitors.DefaultMappingModelVisitor.Visit (IEnumerable1 mappings) [0x00000] in <filename unknown>:0
[exec] at FluentNHibernate.PersistenceModel.ApplyVisitors (IEnumerable
1 mappings) [0x00000] in :0
[exec] at FluentNHibernate.PersistenceModel.BuildMappings () [0x00000] in :0
[exec] at FluentNHibernate.PersistenceModel.EnsureMappingsBuilt () [0x00000] in :0
[exec] at FluentNHibernate.PersistenceModel.Configure (NHibernate.Cfg.Configuration cfg) [0x00000] in :0
[exec] at FluentNHibernate.ConfigurationHelper.AddMappingsFromAssembly (NHibernate.Cfg.Configuration configuration, System.Reflection.Assembly assembly) [0x00000] in :0
[exec] at CodeSharp.Core.Castles.FluentNHibernateConfigurationBuilder+<>c__DisplayClass2.b__0 (IConfiguration o) [0x00000] in :0
[exec] at System.Collections.Generic.List1[Castle.Core.Configuration.IConfiguration].ForEach (System.Action1 action) [0x00000] in :0
[exec] at CodeSharp.Core.Castles.FluentNHibernateConfigurationBuilder.GetConfiguration (IConfiguration facilityConfiguration) [0x00000] in :0
[exec] at Castle.Facilities.NHibernateIntegration.NHibernateFacility.ConfigureFactories (Castle.Facilities.NHibernateIntegration.NHibernateFactoryConfiguration config, ISessionFactoryResolver sessionFactoryResolver, Boolean firstFactory) [0x00000] in :0
[exec] at Castle.Facilities.NHibernateIntegration.NHibernateFacility.ConfigureFacility () [0x00000] in :0
[exec] at Castle.Facilities.NHibernateIntegration.NHibernateFacility.Init () [0x00000] in :0
[exec] at Castle.MicroKernel.Facilities.AbstractFacility.Castle.MicroKernel.IFacility.Init (IKernel kernel, IConfiguration facilityConfig) [0x00000] in :0
[exec] at Castle.MicroKernel.DefaultKernel.AddFacility (IFacility facility) [0x00000] in :0
[exec] at Castle.Windsor.WindsorContainer.AddFacility (IFacility facility) [0x00000] in :0
[exec] at Castle.Windsor.Installer.DefaultComponentInstaller.SetUpFacilities (Castle.Core.Configuration.IConfiguration[] configurations, IWindsorContainer container, IConversionManager converter) [0x00000] in :0
[exec] at Castle.Windsor.Installer.DefaultComponentInstaller.SetUp (IWindsorContainer container, IConfigurationStore store) [0x00000] in :0
[exec] at Castle.Windsor.WindsorContainer.Install (Castle.MicroKernel.Registration.IWindsorInstaller[] installers, Castle.Windsor.Installer.DefaultComponentInstaller scope) [0x00000] in :0
[exec] at Castle.Windsor.WindsorContainer.Install (Castle.MicroKernel.Registration.IWindsorInstaller[] installers) [0x00000] in :0
[exec] at (wrapper remoting-invoke-with-check) Castle.Windsor.WindsorContainer:Install (Castle.MicroKernel.Registration.IWindsorInstaller[])
[exec] at CodeSharp.Core.Castles.ConfigurationExtensions.Castle (CodeSharp.Core.Configuration configuration, System.Action`1 func) [0x00000] in :0
[exec] at Cooper.Model.Test.TestBase.TestFixtureSetUp () [0x00000] in :0

@wsky wsky was assigned
@wsky
Owner

https://github.com/jagregory/fluent-nhibernate/blob/master/src/FluentNHibernate/Visitors/DefaultMappingModelVisitor.cs#L127
error occur here

public override void Visit(ColumnMapping columnMapping)
        {
            columnMapping.AcceptVisitor(this);
        }

columnMapping is null

and why?

@wsky
Owner

https://github.com/jagregory/fluent-nhibernate/blob/master/src/FluentNHibernate/MappingModel/Collections/LayeredColumns.cs#L20

i compile it under mono runtime, and debug into it,
i found:

var maxLayer = layeredValues.Keys.Max();
                var values = ((HashSet<ColumnMapping>)layeredValues[maxLayer]);

                foreach (var value in values)
                {
                    yield return value;
                }

eg: values will have null element:

((HashSet<ColumnMapping>)layeredValues[maxLayer])

and try below got none exception..

ublic void AddColumn(int layer, ColumnMapping mapping)
        {
            if(mapping==null)
                throw new Exception();

look like confused..

is it a bug of mono?

HashSrt on mono not work well

@wsky
Owner

someone had find it
jagregory/fluent-nhibernate#156

@wsky wsky closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.