Ambiguous Component Reference Exception
My project is dependant upon another project. But, my tests are failing because of some class in the dependant project(this project's tests are running fine) with the following error:
Test 'sometest' failed: 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.
----> FluentNHibernate.Visitors.AmbiguousComponentReferenceException : Multiple external components for 'CInformation', referenced from property 'ACInformation' of 'AC', unable to continue.
at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
at sss.SqlLite_TestFixtureBase.SetupContext() in C:..................\SqlLite_TestFixtureBase.cs:line 89
--FluentConfigurationException at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration()
at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
--AmbiguousComponentReferenceException at FluentNHibernate.Visitors.ComponentReferenceResolutionVisitor.ProcessComponent(ReferenceComponentMapping mapping)
at FluentNHibernate.MappingModel.ClassBased.ReferenceComponentMapping.AcceptVisitor(IMappingModelVisitor visitor)
at FluentNHibernate.Visitors.DefaultMappingModelVisitor.Visit(IComponentMapping componentMapping)
at FluentNHibernate.MappingModel.MappedMembers.AcceptVisitor(IMappingModelVisitor visitor)
at FluentNHibernate.MappingModel.ClassBased.ClassMappingBase.AcceptVisitor(IMappingModelVisitor visitor)
at FluentNHibernate.MappingModel.ClassBased.ClassMapping.AcceptVisitor(IMappingModelVisitor visitor)
at FluentNHibernate.Visitors.DefaultMappingModelVisitor.Visit(ClassMapping classMapping)
at FluentNHibernate.MappingModel.HibernateMapping.AcceptVisitor(IMappingModelVisitor visitor)
at FluentNHibernate.Visitors.DefaultMappingModelVisitor.b__0(HibernateMapping x)
at FluentNHibernate.Utils.CollectionExtensions.EachT
at FluentNHibernate.Visitors.DefaultMappingModelVisitor.Visit(IEnumerable1 mappings) at FluentNHibernate.PersistenceModel.ApplyVisitors(IEnumerable
1 mappings)
at FluentNHibernate.PersistenceModel.BuildMappings()
at FluentNHibernate.PersistenceModel.EnsureMappingsBuilt()
at FluentNHibernate.PersistenceModel.Configure(Configuration cfg)
at FluentNHibernate.Cfg.FluentMappingsContainer.Apply(Configuration cfg)
at FluentNHibernate.Cfg.MappingConfiguration.Apply(Configuration cfg)
at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration() C:............................\ 89
Any ideas appreciated. Thanks!!
Support Staff 2 Posted by James Gregory on 25 Aug, 2010 08:45 PM
It's saying that when resolving the mapping for the ACInformation property
it's finding multiple definitions and doesn't know what to do. You either
have multiple ComponentMap<CInformation>'s defined, or you're registering
the same one multiple times with FNH.
On Wed, Aug 25, 2010 at 9:18 PM, Sravanthi <
***@tenderapp.com<tender%***@tenderapp.com>
> wrote:
3 Posted by Sravanthi on 25 Aug, 2010 09:42 PM
Thank you for the quick reply Mr.Gregory. I made sure that Im not doing multiple mappings. What is Registering with Fluent NHibernate mean? You mean in TestFixtureBase Class??
Support Staff 4 Posted by James Gregory on 25 Aug, 2010 10:23 PM
Yes, wherever you're using Fluently.Configure is where you're registering
your mappings with Fluent NHibernate. Show us the code and we might be able
to be more helpful.
On Wed, Aug 25, 2010 at 10:44 PM, Sravanthi <
***@tenderapp.com<tender%***@tenderapp.com>
> wrote:
5 Posted by Sravanthi on 27 Aug, 2010 04:16 PM
Sorry, I cant put out the code here. But, here's how i have my mappings ::
Person is a project with folders Name and Location
In my mappings I have
m.FluentMappings.AddFromAssemblyOf()
m.FluentMappings.AddFromAssemblyOf();
I think this is where I am configuring the same project 2 times. is there any way that i can configure "each class" in Location separately ?
6 Posted by Sravanthi on 27 Aug, 2010 07:53 PM
Never Mind, I used Map instead of References in the Mapping. But, the error i was getting was so misleading.