Load assembly with hibernate DB access error

Arkady's Avatar

Arkady

15 Jul, 2010 11:58 AM via web

Hello,

could you please give me some advice - how to solve the problem.
I have Master program and slave. Master program loads slave prog assembly and does some operations using slave assembly public methods. Each of them use FluentNHibernate to access DB.

Once i load slave assembly and initialize Type with activator, any method which uses Nhibernate in slave rises exception:
Could not compile the mapping document: (XmlDocument)

Whts this about?

Any advice would be welcome!

  1. 2 Posted by Arkady on 19 Jul, 2010 07:05 AM

    Arkady's Avatar

    Any suggestion?

    Or i seem will have to stop using FH on side of loaded asseblys, and use config files or so... =(

  2. 3 Posted by Arkady on 20 Jul, 2010 12:14 PM

    Arkady's Avatar

    Solved

  3. Support Staff 4 Posted by James Gregory on 22 Jul, 2010 11:01 AM

    James Gregory's Avatar

    Care to share the solution invade anyone else encounters the issue?

  4. 5 Posted by Arkady on 23 Jul, 2010 08:16 AM

    Arkady's Avatar

    Solution pretty simple.
    Main problem - .NET could not locate map class for loaded assembly.

    Solution:

    Put handler to workout this kind of situations - AppDomain.CurrentDomain.AssemblyResolve +=

                new ResolveEventHandler(CurrentDomain_AssemblyResolve);
    

    Handler body:
    static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)

        {
            try
            {
                Assembly assembly = System.Reflection.Assembly.Load(args.Name);
    
                if (assembly != null)
    
                    return assembly;
            }
            catch {}
            return Assembly.GetExecutingAssembly();
    
        }
    

Reply to this discussion

Preview Comments are parsed with Markdown. Help with syntax

Attached Files

    You can attach files up to 10MB

    What day comes after Monday?