Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

Compiler Warning (level 1) CS0688

'member1' (a method, property accessor, or event accessor) has a link demand, but overrides or implements 'member2' (a method, property accessor, or event accessor) which does not have a link demand. A security hole may exist.

The following sample generates CS0688. To resolve the warning, remove the security attribute from the overriding method.

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

class Base 
{
   public virtual void DoScaryFileStuff()
   {
   }
}

class Derived: Base
{
   // To resolve the error, remove the following security attribute:
   [FileIOPermission(SecurityAction.LinkDemand)] // CS0688
   public override void DoScaryFileStuff()
   {
   }
   static void Main()
   {
   }
} 

Alternatively, you could add the security attribute to the base overridden method as follows:

// CS0688b.cs
using System;
using System.Security.Permissions;

class Base 
{
   [FileIOPermission(SecurityAction.LinkDemand, All=@"C:\\")]
   public virtual void DoScaryFileStuff()
   {
   }
}

class Derived: Base
{
   [FileIOPermission(SecurityAction.LinkDemand, All=@"C:\\")]

   public override void DoScaryFileStuff()
   {
   }
   static void Main()
   {
   }
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.