Compiler Warning (level 1) CS0688
'method1' has a link demand, but overrides or implements 'method2' which does not have a link demand. A security hole may exist.
The link demand set up on the derived class method can easily be circumvented by calling the base class method. To close the security hole, the base class method needs to also use the link demand. For more information, see Demand vs. LinkDemand.
The following sample generates CS0688. To resolve the warning without modifying the base class, remove the security attribute from the overriding method. This will not solve the security problem.
// 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()
{
}
}
.NET feedback
.NET is an open source project. Select a link to provide feedback: