C
C#β€’13mo ago
reeeeeee

βœ… Problems with NHibernate, FluentNHibernate, StructureMap

I have been trying to fix this bug in an older project (which needed to be updated to .net framework 4.6.1, because of some other newer libraries), but I just didn't really make any progress. I will post some of the stack trace, but please let me know what else should I include (except whole project, lol), so it would be easier to help.
FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at FluentNHibernate.AssemblyTypeSource.GetTypes()
at FluentNHibernate.PersistenceModel.AddMappingsFromSource(ITypeSource source)
at FluentNHibernate.Cfg.FluentMappingsContainer.Apply(PersistenceModel model)
at FluentNHibernate.Cfg.MappingConfiguration.Apply(Configuration cfg)
at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration()
--- End of inner exception stack trace ---
at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration()
at TimeSpace.DataAccess.Persistence.Configuration.NHDatabaseConfiguration.CreateConfiguration()
at TimeSpace.DataAccess.Persistence.Configuration.NHDatabaseConfiguration.CreateFactory()
at TSTrumpet.Web.DataAccessRegistry.<>c.<.ctor>b__1_0(IContext ctx) in C:\Users\naczup\tstrumpet\TSTrumpet.Web\DataAccessRegistry.cs:line 26
at StructureMap.Pipeline.LambdaInstance`1.build(Type pluginType, BuildSession session)
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at FluentNHibernate.AssemblyTypeSource.GetTypes()
at FluentNHibernate.PersistenceModel.AddMappingsFromSource(ITypeSource source)
at FluentNHibernate.Cfg.FluentMappingsContainer.Apply(PersistenceModel model)
at FluentNHibernate.Cfg.MappingConfiguration.Apply(Configuration cfg)
at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration()
--- End of inner exception stack trace ---
at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration()
at TimeSpace.DataAccess.Persistence.Configuration.NHDatabaseConfiguration.CreateConfiguration()
at TimeSpace.DataAccess.Persistence.Configuration.NHDatabaseConfiguration.CreateFactory()
at TSTrumpet.Web.DataAccessRegistry.<>c.<.ctor>b__1_0(IContext ctx) in C:\Users\naczup\tstrumpet\TSTrumpet.Web\DataAccessRegistry.cs:line 26
at StructureMap.Pipeline.LambdaInstance`1.build(Type pluginType, BuildSession session)
5 Replies
reeeeeee
reeeeeeeβ€’13mo ago
could be something in webconfig? or any other config? the code which is executing is this:
return NHDatabaseConfiguration.Configure()
.Database(() =>
DatabaseConfigurer.GetConfigurer(TSeConfiguration.GetServerKind(), StandardDatabaseCredentialStore.Default)
)
.Mappings(mappings => mappings.FluentMappings
.AddFromAssemblyOf<Setting>()
.AddFromAssemblyOf<ApplicationApiKeyMap>()
.AddFromAssemblyOf<Logging.Auditing.AuditEntryMap>()
.AddFromAssemblyOf<DataAccess.Mappings.UserMap>()
.Conventions
.Add<EnumAsIntConvention>()
)
.CreateFactory();
return NHDatabaseConfiguration.Configure()
.Database(() =>
DatabaseConfigurer.GetConfigurer(TSeConfiguration.GetServerKind(), StandardDatabaseCredentialStore.Default)
)
.Mappings(mappings => mappings.FluentMappings
.AddFromAssemblyOf<Setting>()
.AddFromAssemblyOf<ApplicationApiKeyMap>()
.AddFromAssemblyOf<Logging.Auditing.AuditEntryMap>()
.AddFromAssemblyOf<DataAccess.Mappings.UserMap>()
.Conventions
.Add<EnumAsIntConvention>()
)
.CreateFactory();
cap5lut
cap5lutβ€’13mo ago
check what
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
is telling u.
reeeeeee
reeeeeeeβ€’13mo ago
Holy shit this was depressing... Finally found it, it was problem with PostSharp reference. I am not entirely sure why do I need it separately, becuase my project doent use it, but looks like the FLuentNHIbernate was using it so my project needed reference to it as well. Actually, it already had it, but looks like it was broken or something, so when I readded it, it worked. πŸ˜„ Thanks for the advice, had to improve my exception handling to catch that loadedException πŸ˜„
cap5lut
cap5lutβ€’13mo ago
glad that worked out ;p so in future read the exception messages carefully if they dont explicitly tell the actual issue they usually mention how to get more details ;p also if this is finished now please $close the thread πŸ˜‰
MODiX
MODiXβ€’13mo ago
Use the /close command to mark a forum thread as answered
Want results from more Discord servers?
Add your server
More Posts