1
나는 DB에 쓰기를 읽기 위해 SQL에 C#과 Linq를 사용하는 간단한 웹 사이트를 가지고있다. 모든 것은 내 로컬 상자에서 잘 작동하지만 지금은 데이터베이스에 쓰기를 시도 할 때 "보안 예외"가 표시되는 호스팅 환경에 설치가되어 읽기가 정상입니다. 나는 그들이 서버 측에서 할 수있는 모든 것을 구성했다고 말한 호스팅 회사에 연락했다. 이것은 LINQ 쿼리의 예와Linq to SQL - 보안 예외
Linq에 쿼리를 throw되는 예외입니다 :
public void LogLoginAttempt(string Username, string Password, bool isValidated)
{
try
{
Data.ProfileLoginLog pll = new Library.Data.ProfileLoginLog();
pll.Username = Username;
pll.Password = Password;
pll.isValidated = isValidated;
pll.CreateDate = DateTime.Now;
dc.ProfileLoginLogs.InsertOnSubmit(pll);
dc.SubmitChanges();
}
catch (Exception ex)
{
ErrorLog e = new ErrorLog();
e.LogFatalError(ex);
}
}
예외 :
Server Error in '/' Application.
--------------------------------------------------------------------------------
Security Exception
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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed) +150
System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed) +100
System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Object assemblyOrString, SecurityAction action, Boolean throwException) +284
System.Security.PermissionSetTriple.CheckSetDemand(PermissionSet demandSet, PermissionSet& alteredDemandset, RuntimeMethodHandle rmh) +69
System.Security.PermissionListSet.CheckSetDemand(PermissionSet pset, RuntimeMethodHandle rmh) +150
System.Security.PermissionListSet.DemandFlagsOrGrantSet(Int32 flags, PermissionSet grantSet) +30
System.Threading.CompressedStack.DemandFlagsOrGrantSet(Int32 flags, PermissionSet grantSet) +40
System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(Int32 permission, PermissionSet targetGrant, CompressedStack securityContext) +123
System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(Int32 permission, PermissionSet targetGrant, Resolver accessContext) +41
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082
그래, 어떻게 고칠 수 있습니까? – Kieran
이 문제를 해결하는 방법은 두 가지뿐입니다. 리플렉션을 사용하지 않도록 메소드를 변경하거나 리플렉션을 사용하는 데 필요한 보안 등급을 프로세스에 부여하십시오. 원래 응답에서 제공 한 링크에는 필요한 보안 보안을 얻는 방법을 자세히 설명하는 다른 리소스에 대한 링크가 충분하므로 따를 것이 좋습니다. –