Duplicate class mapping with Fluent NHibernate when loaded from multiple assemblies -


i using fluent , nhibernate v2.4 in web application.

because of design have mapping files in several assemblies.

however when try add second assembly mapping (see code below) error saying class (the 1 in second assembly @ point) has been mapped (needless have 1 mapping class per class).

can see i'm going wrong?

the error:

    duplicate class/entity mapping       nhibernate.cfg.mappings.addclass(persistentclass persistentclass) +181    nhibernate.cfg.xmlhbmbinding.joinedsubclassbinder.handlejoinedsubclass(persistentclass model, xmlnode subnode, idictionary`2 inheritedmetas) +1834    nhibernate.cfg.xmlhbmbinding.classbinder.propertiesfromxml(xmlnode node, persistentclass model, idictionary`2 inheritedmetas, uniquekey uniquekey, boolean mutable, boolean nullable, boolean naturalid) +1911    nhibernate.cfg.xmlhbmbinding.classbinder.propertiesfromxml(xmlnode node, persistentclass model, idictionary`2 inheritedmetas) +64    nhibernate.cfg.xmlhbmbinding.rootclassbinder.bind(xmlnode node, hbmclass classschema, idictionary`2 inheritedmetas) +1214    nhibernate.cfg.xmlhbmbinding.mappingrootbinder.addrootclasses(xmlnode parentnode, idictionary`2 inheritedmetas) +270    nhibernate.cfg.xmlhbmbinding.mappingrootbinder.bind(xmlnode node) +162    nhibernate.cfg.configuration.addvalidateddocument(namedxmldocument doc) +262  [mappingexception: not compile mapping document: (xmldocument)]    nhibernate.cfg.configuration.logandthrow(exception exception) +136    nhibernate.cfg.configuration.addvalidateddocument(namedxmldocument doc) +387    nhibernate.cfg.configuration.processmappingsqueue() +74    nhibernate.cfg.configuration.adddocumentthroughqueue(namedxmldocument document) +64    nhibernate.cfg.configuration.addxmlreader(xmlreader hbmreader, string name) +94    nhibernate.cfg.configuration.addinputstream(stream xmlinputstream, string name) +158    nhibernate.cfg.configuration.adddocument(xmldocument doc, string name) +323    nhibernate.cfg.configuration.adddocument(xmldocument doc) +72    fluentnhibernate.persistencemodel.configure(configuration cfg) +751    fluentnhibernate.cfg.fluentmappingscontainer.apply(configuration cfg) +472    fluentnhibernate.cfg.mappingconfiguration.apply(configuration cfg) +332    fluentnhibernate.cfg.fluentconfiguration.buildconfiguration() +108  [fluentconfigurationexception: invalid or incomplete configuration used while creating sessionfactory. check potentialreasons collection, , innerexception more detail.  ]    fluentnhibernate.cfg.fluentconfiguration.buildconfiguration() +325    liath.surveys.dao.nhibernate.burrowfluentconfigurator.config(ipersistenceunitcfg pucfg, configuration nhcfg) in c:\subversion\surveys\source\liath.surveys.dao.nhibernate\burrowfluentconfigurator.cs:49    nhibernate.burrow.impl.persistenceunit..ctor(ipersistenceunitcfg cfg, iconfigurator configurator) +148    nhibernate.burrow.impl.persistenceunitrepo.initialize(iburrowconfig configuration) +212    nhibernate.burrow.impl.frameworkenvironment.start() +185    nhibernate.burrow.impl.frameworkenvironment.reconfig(iconfigurator configurator) +159    nhibernate.burrow.impl.frameworkenvironment..ctor() +55    nhibernate.burrow.impl.frameworkenvironment..cctor() +53  [typeinitializationexception: type initializer 'nhibernate.burrow.impl.frameworkenvironment' threw exception.]    nhibernate.burrow.impl.frameworkenvironment.get_instance() +60    nhibernate.burrow.impl.workspace.get_current() +50    nhibernate.burrow.burrowframework.get_workspaceisready() +59    nhibernate.burrow.burrowframework.closeworkspace() +62    nhibernate.burrow.webutil.webutilhttpmodule.closecontext(object sender, eventargs e) +103    system.web.synceventexecutionstep.system.web.httpapplication.iexecutionstep.execute() +148    system.web.httpapplication.executestep(iexecutionstep step, boolean& completedsynchronously) +75 

here code configurator:

 public void config(ipersistenceunitcfg pucfg, configuration nhcfg)     {         try         {             string[] assemblies =             {                  "assemblya",                 "assemblyb"             }; // todo: push down config              fluentconfiguration fluentcfg = fluently.configure(nhcfg);             fluentcfg = fluentcfg.database(fluentnhibernate.cfg.db.mssqlconfiguration.mssql2005                 .connectionstring(@"server=localhost\sqlexpress;initial catalog=mydatabase;integrated security=sspi"));              foreach (string assemblyname in assemblies)             {                 fluentcfg = fluentcfg.mappings(m => m.fluentmappings.addfromassembly(assembly.load(assemblyname)));             }             fluentcfg.buildconfiguration();         }         catch (exception ex)         {             s_log.error("there error configuring nhibernate", ex);             throw;         }     } 


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -