These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: NHibernate and Dynamic Assemblies
PostPosted: Sat Nov 08, 2008 10:10 am 
Newbie

Joined: Sat Nov 08, 2008 9:50 am
Posts: 1
Hello,

I've defined a class "Customer.cs" with its Xml-File "Customer.hbm.xml" in a dynamically loaded Assembly. When I load the Assembly the reference of this Assembly is returned to the main Assembly where you find my hibernate-initialisation.

My Problem is that NHibernate throws the exception "Could not compile the mapping document: MyProgram.Customer.hbm.xml".
The inner Exception is: "Could not load file or assembly 'AddIn.Customer.Core' or one of its dependencies."

When I add the Assembly statically it's all okay, but I want to use them dynamically. Do I have to register an assembly in my program before I use Configuration.AddAssembly()-Method in my main Assembly?

Code:
private ISessionFactory SessionFactory
        {
            get
            {
                if (_sessionFactory == null)
                {
                    var configuration = new Configuration();
                    configuration.Configure();

                    /* _assemblyCollec becomes filled when plugins are loaded */
                    foreach (Assembly assembly in _assemblyCollec)
                    {
                        configuration.AddAssembly(assembly); // <-- here's the exception
                    }
                   
                    _sessionFactory = configuration.BuildSessionFactory();
                }
                return _sessionFactory;
            }
        }


Thank you very much!
Sandra


Top
 Profile  
 
 Post subject: Re: NHibernate and Dynamic Assemblies
PostPosted: Mon Nov 10, 2008 4:08 am 
Newbie

Joined: Wed Oct 01, 2008 6:07 am
Posts: 7
Please check the build action of the customer.hbm.xml file it should be embedded resource.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.