加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – SecurityException – 共享主机上的Dapper

发布时间:2020-12-16 03:21:48 所属栏目:asp.Net 来源:网络整理
导读:对于我目前的项目,我使用Dapper.一切都很完美.然后我需要在共享主机上部署它.结果可以在这里看到(复制YSOD): Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the require
对于我目前的项目,我使用Dapper.一切都很完美.然后我需要在共享主机上部署它.结果可以在这里看到(复制YSOD):

Description: The application attempted to perform an operation not
allowed by the security policy. To grant this application the
required permission please contact your system administrator or change
the application’s trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the
permission of type ‘System.Security.Permissions.ReflectionPermission,
mscorlib,Version=4.0.0.0,Culture=neutral,
PublicKeyToken=b77a5c561934e089’ failed.

堆栈跟踪

[SecurityException: Request for the permission of type
‘System.Security.Permissions.ReflectionPermission,mscorlib,
Version=4.0.0.0,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) +9461551
System.Reflection.Emit.DynamicMethod..ctor(String name,Type
returnType,Type[] parameterTypes,Type owner,Boolean skipVisibility)
+40 Dapperx.SqlMapper.CreateParamInfoGenerator(Identity identity) +537 Dapperx.SqlMapper.GetCacheInfo(Identity identity) +376 Dapperx.d__131.MoveNext() +644
System.Collections.Generic.List
1..ctor(IEnumerable1 collection) +327
System.Linq.Enumerable.ToList(IEnumerable
1 source) +58
Dapperx.SqlMapper.Query(IDbConnection cnn,String sql,Object param,
IDbTransaction transaction,Boolean buffered,Nullable1
commandTimeout,Nullable
1 commandType) +199

有没有办法解决它(在.NET 4.0中)?
据我所知,到目前为止我所阅读的内容,提供商必须允许一些部分反映IIS,这可能会对他们造成安全风险……

解决方法

在Medium Trust中不允许使用Dapper使用的Reflection.Emit.

您应该找到提供完全信任的托管服务提供商. discountasp.net是我以前用过的.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读