简体   繁体   English

Fluent NHibernate无法为动态程序集自动创建映射

[英]Fluent NHibernate can not auto create mappings for a dynamic assembly

I am working on a legacy code base that builds some of its entities on the fly.I'd like to be able to add these entities to my auto persistent model using AddEntityAssembly like this : 我正在开发一个可即时构建其某些实体的旧代码库,我希望能够使用AddEntityAssembly将这些实体添加到我的自动持久模型中:

var model =new AutoPersistenceModel()
                .AddEntityAssembly(Manager.RunTimeEntityType.Assembly)

When I try to build a configuration using this model I'm getting a FileNotFoundException which confuses me because the assembly is already loaded to AppDomain.CurrentDomain and I can build a new object of RunTimeEntityType using Activator.CreateInstance 当我尝试使用此模型构建配置时,我得到一个FileNotFoundException ,这使我感到困惑,因为程序集已经加载到AppDomain.CurrentDomain并且可以使用Activator.CreateInstance来构建RunTimeEntityType的新对象。

Do I have to do something extra ? 我需要做些额外的事情吗?

OK. 好。 I found out what the problem was.Actually NHibernate had to load this assembly from a different folder that was not introduce as part of the references path.So all I had to do was to add this folder to app.config : 我发现了问题所在,实际上NHibernate不得不从另一个文件夹中加载该程序集,而这个文件夹并没有作为引用路径的一部分引入,所以我要做的就是将该文件夹添加到app.config中:

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <probing privatePath="my folder name" />
  </assemblyBinding>
</runtime>

Here there's a question about the same issue. 这里有一个关于同一问题的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM