Inheritance security rules violated while overriding member - SecurityRuleSet.Level2

前端 未结 5 2085
感动是毒
感动是毒 2020-11-27 21:24

I have a class that inherits from Exception. In .NET 4, I started receiving a runtime error:

Inheritance security rules violated while overriding m

5条回答
  •  盖世英雄少女心
    2020-11-27 22:09

    Mark GetObjectData with SecurityCriticalAttribute, because it's applied to Exception.GetObjectData. An overridden member should have the same security accessibility (Critical, Safe Critical or Transparent).

    Read Security Changes in the .NET Framework 4 and Security Transparent Code, Level 2 from MSDN for more information.

    To avoid all potential security runtime exceptions, enable Code Analysis with the Security rule set. You'll get static analysis warnings that might correspond to runtime errors.

提交回复
热议问题