SecurityException ReflectionPermission:自动映射器

发布于 2024-12-26 03:55:55 字数 1836 浏览 3 评论 0原文

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

"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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凌乱心跳 2025-01-02 03:55:55

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

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

Just add this line to Web.Config and it's solved.
http://msdn.microsoft.com/en-us/library/tkscy493.aspx

<trust level="Full" originUrl="" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文