【发布时间】:2018-06-26 13:10:05
【问题描述】:
//格式化不正确。
使用nhibernate和.net core编写的nopcommerce插件,每个插件都包含自己的实体目录,但是当NHibernate配置失败时
var cfg = new Configuration();
cfg.Configure(CommonHelper.MapPath("~/App_Data/db/defauls.config"));
// error here
cfg.AddAssembly("plugins assembly name");
FileNotFoundException:无法加载文件或程序集“插件程序集名称”或其依赖项之一。系统找不到指定的文件。
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, string codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, ref StackCrawlMark stackMark, IntPtr pPrivHostBinder, bool throwOnFileNotFound, bool forIntrospection, bool suppressSecurityChecks) MappingException:持久类“插件程序集名称.Entities.class 名称,插件程序集名称找不到
NHibernate.Cfg.XmlHbmBinding.Binder.ClassForFullNameChecked(string fullName, string errorMessage) MappingException:无法编译映射文档:插件程序集名称.Entities.class name.hbm.xml
NHibernate.Cfg.Configuration.LogAndThrow(Exception exception)
【问题讨论】:
-
如果插件中的 cfg 或非嵌入式资源 hbm.xml 文件没有发生错误,我认为问题不在于 NHibernate,它与我加载程序集的方式有关,但不知道如何解决
-
请将程序集名称与您的插件命名空间一起传递。如果您的插件命名空间是 Nop.Plugin.Misc.Name 并且 DLL 程序集名称是 MyExample.Core.DLL 则您必须传递
Nop.Plugin.Misc.Name.MyExample.Core这将适用于在插件中添加程序集。 -
命名空间 Plugin.Shop.Entities,在 Plugin.Shop.Entities 中组装 Plugin.Shop 我有类 Amounts.cs 和文件 Amounts.hbm.xml
-
比传入 Plugin.Shop.Entities.Plugin.Shop 程序集名称
-
您可以在插件根文件夹中添加 DLL 并从中提供参考
标签: nhibernate .net-core nhibernate-mapping