gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 10:17:42 31 4
gpt4 key购买 nike

对于我当前的项目,我使用 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, 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) +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<br/>
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这是我以前用过的。

关于asp.net - SecurityException - 共享主机上的 Dapper,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10780278/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com