我正在使用 NHibernate 开发一个 ASP.NET MVC 应用程序,并且我正在尝试使用 Automapper 从发送到视图的 DTO 对象中隐藏域对象:
- 带有我的域(用于 NHibernate)和 DTO 对象的 ClassLibrary
SessionFactory
在我的项目中创建和工厂的类库
我下载了 AutoMapper 来转换 DTO 中的域对象,并在Application_Start
.
当我在 VisualStudio 中运行应用程序(按 F5)时,它工作正常,并且我的 DTO 被映射到视图中。
当我在 IIS 中发布它时,我得到一个安全异常:
Mapper.CreateMap<Category, CategoryDto>();
Mapper.CreateMap<Product, ProductDto>();
System.Security.SecurityException:请求“System.Security.Permissions.ReflectionPermission,mscorlib,版本=2.0.0.0,文化=中性,PublicKeyToken=b77a5c561934e089”类型的权限失败。
如何让 Automapper 在没有安全异常的情况下工作?