컴파일러 경고(수준 1) CS0688

업데이트: 2007년 11월

오류 메시지

링크 요청이 있는 'method1'에서 링크 요청이 없는 'method2'을(를) 재정의 또는 구현합니다. 보안상 위험할 수도 있습니다.
'method1' has a link demand, but overrides or implements 'method2' which does not have a link demand. A security hole may exist.

파생 클래스 메서드의 링크 요청 설정은 기본 클래스 메서드 호출에 의해 손상되기 쉽습니다. 보안 허점을 없애려면 기본 클래스 메서드에서도 링크 요청을 사용해야 합니다. 자세한 내용은 Demand와 LinkDemand 비교를 참조하십시오.

예제

다음 샘플에서는 CS0688 오류가 발생하는 경우를 보여 줍니다. 기본 클래스를 수정하지 않고 이 경고를 해결하려면 재정의하는 메서드에서 보안 특성을 제거합니다. 이렇게 해도 보안 문제는 해결되지 않습니다.

// CS0688.cs
// compile with: /W:1
using System;
using System.Security.Permissions;

class Base 
{
    //Uncomment the following line to close the security hole
    //[FileIOPermission(SecurityAction.LinkDemand, All=@"C:\\")]
    public virtual void DoScaryFileStuff()
    {
    }
}

class Derived: Base
{
    [FileIOPermission(SecurityAction.LinkDemand, All=@"C:\\")] // CS0688
    public override void DoScaryFileStuff()
    {
    }
    static void Main()
    {
    }
}