抛出:SecurityException - 小巧玲珑的共享主机小巧玲珑、抛出、主机、SecurityException

2023-09-08 09:37:48 作者:习之孤往

有关我目前的项目,我用小巧精致。一切都完美。然后,我需要在共享主机部署。其结果可以在这里看到(复制YSOD):

For my current project I use Dapper. Everything perfect. Then I needed to deploy it on shared hosting. The result can be seen here (copied 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.

异常详细信息:System.Security.SecurityException:请求   权限类型的System.Security.Permissions.ReflectionPermission,   mscorlib程序,版本= 4.0.0.0,文化=中立,   公钥= b77a5c561934e089失败。

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异常:请求类型的权限   System.Security.Permissions.ReflectionPermission,mscorlib程序,   版本= 4.0.0.0,文化=中性公钥= b77a5c561934e089'   失败。] System.Security程序。codeAccessSecurityEngine.Check(对象   需求,StackCrawlMark和放大器; stackMark,布尔isPermSet)+ 0   System.Security程序。codeAccessSecurityEngine.Check(codeAccessPermission   帽,StackCrawlMark和放大器; stackMark)+31   System.Security程序。codeAccessPermission.Demand()+46   System.Reflection.Emit.DynamicMethod.PerformSecurityCheck(类型所有者,   StackCrawlMark和放大器; stackMark,布尔skipVisibility)9461551   System.Reflection.Emit.DynamicMethod..ctor(字符串名称,类型   返回类型,类型[] parameterTypes,主人型,布尔skipVisibility)   + 40 Dapperx.SqlMapper.CreateParamInfoGenerator(身份识别)537 Dapperx.SqlMapper.GetCacheInfo(身份识别)+376 Dapperx.d__13 1.MoveNext()644   System.Collections.Generic.List 1..ctor(IEnumerable的 1集)327   System.Linq.Enumerable.ToList(IEnumerable的 1的源)+58   Dapperx.SqlMapper.Query(美国有线电视新闻网的IDbConnection,SQL字符串,对象参数,   IDbTransaction交易,布尔缓冲,可空 1   的CommandTimeout,可空 1命令类型)+1​​99   ......

[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 System.Collections.Generic.List1..ctor(IEnumerable1 collection) +327 System.Linq.Enumerable.ToList(IEnumerable1 source) +58 Dapperx.SqlMapper.Query(IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable1 commandTimeout, Nullable1 commandType) +199 ...

有什么办法如何解决它(在.NET 4.0中)? 据我了解到目前为止我读,供应商必须允许从反射的IIS的某些部分可能是他们的一个安全隐患......

Is there any way how to solve it for (in .NET 4.0)? As far as I understand what I've read so far, the provider has to allow some parts from reflection for the IIS which might be a security risk for them...

推荐答案

Reflection.Emit的这是由小巧玲珑没有在中等信任允许的。

Reflection.Emit which is used by Dapper is not allowed in Medium Trust.

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

You should find a hosting provider that offers Full Trust. discountasp.net is one I have used before.