fluent-nhibernate icon indicating copy to clipboard operation
fluent-nhibernate copied to clipboard

Unable to add overrides when using an inherited PersistenceModel

Open Philo opened this issue 14 years ago • 1 comments

.UseOverridesFromAssemblyOf<>() and .UseOverridesFromAssembly() when used within an inherited PersistenceModel cause an "Object reference not set to an instance of an object" exception at line 366 of FluentNhibernate/automapping/AutoPersistenceModel.cs.

The attempt to retrieve a reference to the "OverrideHelper" method via this.GetType() returns null:

                    var overrideInstance = Activator.CreateInstance(overrideType);
                    GetType()
                        .GetMethod("OverrideHelper", BindingFlags.NonPublic | BindingFlags.Instance)
                        .MakeGenericMethod(entityType)
                        .Invoke(this, new [] {x, overrideInstance});

    private void OverrideHelper<T>(AutoMapping<T> x, IAutoMappingOverride<T> mappingOverride)
    {
        mappingOverride.Override(x);
    }

Philo avatar Aug 23 '11 14:08 Philo

Possible fix would be to alter the OverrideHelper access modifier from private to protected. Trying this resolved my own problem

Philo avatar Aug 23 '11 14:08 Philo