다음을 통해 공유


SYSLIB0003: 코드 액세스 보안이 지원되지 않습니다.

CAS(코드 액세스 보안) 는 지원되지 않는 레거시 기술입니다. .NET Framework 2.x - 4.x에만 존재하는 CAS를 사용하도록 설정하는 인프라는 더 이상 사용되지 않으며 서비스 또는 보안 수정을 받지 않습니다.

따라서 .NET 5부터 .NET의 CAS(코드 액세스 보안) 관련 형식은 대부분 사용되지 않습니다. 여기에는 CAS 권한 개체(예: SecurityPermissionAttribute파생 형식) 및 기타 지원 API와 같은 SocketPermissionEvidenceBaseCAS 특성이 포함됩니다. 이러한 API를 사용하면 컴파일 시간에 경고 SYSLIB0003 가 생성됩니다.

사용되지 않는 CAS API의 전체 목록은 다음과 같습니다.

해결 방법

  • 보안 권한을 어설션하는 경우 권한을 어설션하는 특성 또는 호출을 제거합니다.

    // REMOVE the attribute below.
    [SecurityPermission(SecurityAction.Assert, ControlThread = true)]
    public void DoSomething()
    {
    }
    public void DoAssert()
    {
        // REMOVE the line below.
        new SecurityPermission(SecurityPermissionFlag.ControlThread).Assert();
    }
    
  • 사용 권한을 PermitOnly를 통해 거부하거나 제한하는 경우 보안 관리자에게 문의하세요. CAS 특성은 .NET 5+ 런타임에서 적용되지 않으므로 이러한 메서드에 대한 액세스를 제한하기 위해 CAS 인프라를 잘못 사용하는 경우 애플리케이션에 보안 구멍이 있을 수 있습니다.

    // REVIEW the attribute below; could indicate security vulnerability.
    [SecurityPermission(SecurityAction.Deny, ControlThread = true)]
    public void DoSomething()
    {
    }
    public void DoPermitOnly()
    {
        // REVIEW the line below; could indicate security vulnerability.
        new SecurityPermission(SecurityPermissionFlag.ControlThread).PermitOnly();
    }
    
  • 사용 권한을 요구하는 경우(PrincipalPermission 제외), 요구를 제거하세요. 모든 요구는 런타임에 성공합니다.

    // REMOVE the attribute below; it will always succeed.
    [SecurityPermission(SecurityAction.Demand, ControlThread = true)]
    public void DoSomething()
    {
    }
    public void DoDemand()
    {
        // REMOVE the line below; it will always succeed.
        new SecurityPermission(SecurityPermissionFlag.ControlThread).Demand();
    }
    
  • 요구하는 PrincipalPermission인 경우 SYSLIB0002: PrincipalPermissionAttribute는 더 이상 사용되지 않습니다에 대한 지침을 참조하세요. 해당 지침은 둘 다 PrincipalPermissionPrincipalPermissionAttribute적용됩니다.

경고 표시 안 함

사용되지 않는 API를 사용해야 하는 경우 코드 또는 프로젝트 파일에서 경고를 표시하지 않을 수 있습니다.

단일 위반만 표시하지 않으려면 소스 파일에 전처리기 지시문을 추가하여 경고를 사용하지 않도록 설정한 다음 다시 사용하도록 설정합니다.

// Disable the warning.
#pragma warning disable SYSLIB0003

// Code that uses obsolete API.
// ...

// Re-enable the warning.
#pragma warning restore SYSLIB0003

프로젝트의 모든 SYSLIB0003 경고를 억제하려면, 프로젝트 파일에 <NoWarn> 속성을 추가하세요.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
   ...
   <NoWarn>$(NoWarn);SYSLIB0003</NoWarn>
  </PropertyGroup>
</Project>

자세한 내용은 경고 표시 안 함을 참조하세요.

참고하십시오