FluentNHibernate exception - Could not compile the mapping document

683 Views Asked by At

Before posting this question I reviewed:

Runtime error when trying to run Fluent NHibernate tutorial example

Fluent nHibernate error - Could not compile the mapping document: (XmlDocument)

and many more similar questions which I was hoping could shed some light on my issue. No luck so far:

I was working a solution for some time now and everything was going fine until my most recent change. The solution still compiles but fails on startup with this exception:

An unhandled exception of type 'FluentNHibernate.Cfg.FluentConfigurationException' occurred in xx.Initialization.dll

in View Details it says:

An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail."

PotentialReasons: Count = 0

InnerException: Could not compile the mapping document: xx.Website.Persistence.Repository.Mappings.UI.yyDataDto.hbm.xml

Inner exception: JIT Compiler encountered an internal limitation.

The .hbm.xml file that the exception is referring to is intact and there were no changed made to it. All of my code changes are covered by tests and whatever I changed doesn't seem to involve the exception directly.

To troubleshoot this, I committed and pushed all of my changes (feature branch) and asked my co-worker to get latest version. He was able to run the solution without any exceptions. I tried restarting my VS2013, my workstation, deleting my repository and getting the solution from scratch through source control as well as by a direct copy of my co-worker's solution folder (latest version) and still receiving the same error.

Not sure what else to try. Any tips/suggestions would be greatly appreciated. Thanks!

edit/update:

Today I attempted to repair my VS2013 installation, that didn't help. I then updated to latest service pack 4. Also no results.

I'm guessing at this point that something may be wrong with my debugger/settings because if I build the project and launch it (without debugging or by navigating to Bin folder and executing directly) it runs without exceptions. If I debug, I get the exception.

Here's the stacktrace:

   at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
   at Company.Framework.Startup.Behaviour.NHibernateMultiDbBehaviour`2.ConfigureSessionFactory[TFluentMapping](String defaultSchema, String connectionStringKey)
   at Company.Framework.Startup.Behaviour.NHibernateMultiDbBehaviour`2.<>c__DisplayClassa`1.<RegisterNHibernate>b__5()
   at Castle.MicroKernel.Registration.ComponentRegistration`1.<>c__DisplayClassf`1.<UsingFactoryMethod>b__e(IKernel k, ComponentModel m, CreationContext c)
   at Castle.MicroKernel.ComponentActivator.FactoryMethodActivator`1.Instantiate(CreationContext context)
   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context)
   at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context)
   at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext context)
   at Castle.MicroKernel.Lifestyle.SingletonLifestyleManager.Resolve(CreationContext context)
   at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired)
   at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context, Boolean instanceRequired)
   at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context)
   at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, IDictionary additionalArguments)
   at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service)
   at Castle.MicroKernel.DefaultKernel.Resolve(String key, Type service)
   at Castle.MicroKernel.DefaultKernel.Resolve[T](String key)
   at Company.Framework.Startup.Behaviour.NHibernateMultiDbBehaviour`2.<>c__DisplayClassa`1.<RegisterNHibernate>b__7(IKernel kernel)
   at Castle.MicroKernel.Registration.ComponentRegistration`1.<>c__DisplayClass12`1.<UsingFactoryMethod>b__11(IKernel k, ComponentModel m, CreationContext c)
   at Castle.MicroKernel.ComponentActivator.FactoryMethodActivator`1.Instantiate(CreationContext context)
   at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context)
   at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context)
   at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationContext context)
   at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired)
   at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context, Boolean instanceRequired)
   at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context)
   at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, IDictionary additionalArguments)
   at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service)
   at Castle.MicroKernel.DefaultKernel.Resolve(String key, Type service)
   at Castle.Windsor.WindsorContainer.Resolve[T](String key)
   at Company.Framework.Startup.Behaviour.NHibernateMultiDbBehaviour`2.RegisterNHibernate[TFluentMapping](String factoryName, String sessionName, String defaultSchema, String connectionStringKey)
   at Company.Framework.Startup.Behaviour.NHibernateMultiDbBehaviour`2.Start()
   at Company.Framework.Startup.Behaviour.BehaviourManager.AddAndInitialize[T](Action`1 initialize)
   at Company.Framework.Startup.Behaviour.BehaviourManager.Add[T](Action`1 initialize)
   at Company.Project.Initialization.ServiceInitializator.ConfigureBehaviours() in c:\Path\Project.Initialization\ServiceInitializator.cs:line 99
1

There are 1 best solutions below

0
On BEST ANSWER

The solution was to uninstall VS2013 completely and re-install it from scratch. After I did that, the exception went away.

I tried to remember what could've caused this and so far my only suspicion is that maybe when I ran CCleaner (prior to this issue appearing), it removed files or registry entries which made VS behave in such a way.