AutoMapper and SecurityException in IIS
- by Felipe
Hi everybody... I'm developing a asp.net mvc application with nhibernate and I would not like to expose my objects mappings with NHibernate, so I created DTO for each entity and I'm trying to convert my Domain objects to DTO and send it to View. So I have in my sollution:
ClassLibrary with my Domain (for NHibernate) and DTO objetcs
Class library to make a SessionFactory adn Factories in my Project
Asp.Net MVC 2 Application
So, I download AutoMapper to transform Domain objects in DTO and add a the code to do this in Application_Start of global.asax.
When I run in VisualStudio (by pressing F5) it works fine and my dtos are into the view, So when I publish this in IIS, I get a security exception =( in first line of conversion:
Mapper.CreateMap(); <--- this line throw exception
Mapper.CreateMap();
System.Security.SecurityException: Failed request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
What can I do to resolve this to work in IIS ? When I will publish it on web server, the error will get too :(
Thanks
Cheers