SecurityException ReflectionPermission:自动映射器
我使用共享虚拟主机时遇到以下错误:
"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
I'm getting the following error using a shared 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."
I think that this should be related to AutoMapper. How can I solve this?
Following the Stack Trace:
[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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需将这一行添加到 Web.Config 即可解决。
http://msdn.microsoft.com/en-us/library/tkscy493.aspx
Just add this line to Web.Config and it's solved.
http://msdn.microsoft.com/en-us/library/tkscy493.aspx