Inheritance security rules violated while overriding member - SecurityRuleSet.Level2

Posted by Page Brooks on Stack Overflow See other posts from Stack Overflow or by Page Brooks
Published on 2010-06-16T17:41:12Z Indexed on 2010/06/16 18:02 UTC
Read the original article Hit count: 1017

Filed under:
|

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

Inheritance security rules violated while overriding member: MyBusinessException.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.

I think the issue is caused by the fact that I am overriding GetObjectData.

I know one answer for resolving the issue is to set the SecurityRuleSet:

[assembly: SecurityRules(SecurityRuleSet.Level1)]

This is not an acceptable answer, I'd like to know how to fix the issue without having to relax the default security rules in .NET 4.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about security