SecurityException ReflectionPermission:Automapper

时间:2012-01-10 18:42:54

标签: security model-view-controller automapper web-hosting

我使用共享虚拟主机收到以下错误:

"System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."

我认为这应与AutoMapper相关。我该如何解决这个问题?

跟踪堆栈跟踪:

[SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
   System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
   System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark) +31
   System.Security.CodeAccessPermission.Demand() +46
   System.Reflection.Emit.DynamicMethod.PerformSecurityCheck(Type owner, StackCrawlMark& stackMark, Boolean skipVisibility) +9453167
   System.Reflection.Emit.DynamicMethod..ctor(String name, Type returnType, Type[] parameterTypes, Type owner, Boolean skipVisibility) +40
   AutoMapper.DelegateFactory.CreateDynamicMethod(MemberInfo member, Type sourceType) +291
   AutoMapper.DelegateFactory.CreateSet(PropertyInfo property) +52
   AutoMapper.Internal.PropertyAccessor..ctor(PropertyInfo propertyInfo) +64
   AutoMapper.ReflectionHelper.ToMemberAccessor(MemberInfo accessorCandidate) +209
   AutoMapper.TypeMapFactory.CreateTypeMap(Type sourceType, Type destinationType, IMappingOptions options) +256
   AutoMapper.ConfigurationStore.CreateTypeMap(Type source, Type destination, String profileName) +83
   AutoMapper.ConfigurationStore.CreateMap(String profileName) +92
   AutoMapper.ConfigurationStore.CreateMap() +53
   AutoMapper.Mapper.CreateMap() +76

1 个答案:

答案 0 :(得分:1)

只需将此行添加到Web.Config即可解决。 http://msdn.microsoft.com/en-us/library/tkscy493.aspx

<trust level="Full" originUrl="" />