开发者

Mapping classes from Assemblies which are stored in a Different Folder

I'm trying to build an extensible application using MEF and fluent Nhibernate as ORM. It was working well until I decided to store the extension assemblies in a seperate fold开发者_JAVA技巧er (\Extensions). MEF loads the extensions without any problem, but nhibernate throws exceptions because it can't locate the assembly.

Is there a way to add the Extensions Folder to the Assembly searchpath?

MEF Composition:

[ImportMany]
public IEnumerable<IModule> Modules { get; private set; }

public void LoadModules()
{
    _initialized = false;
    var catalog = new DirectoryCatalog("Extensions");
    var container = new CompositionContainer(catalog);
    container.ComposeParts(this);

}

Mapping:

foreach (var module in modules)
{
    var assembly = module.GetType().Assembly;
    config.Mappings(m => m.FluentMappings.AddFromAssembly(assembly));
}


If I'm understanding your question correctly, there are a couple of options:

AppDomain.CurrentDomain.SetupInformation.PrivateBinPath will work if your Extension directory is or is in a subdirectory of the application's directory.

Alternatively, you could handle the AppDomain.AssemblyResolve event.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜