I’ve encountered a new exception when using ASP.NET 4.0 Beta 2.
Inheritance security rules violated while overriding member: 'PeterBlum.DataSources.EntityDAO.SelectArgs.System.Runtime.Serialization.ISerializable.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.
This occurred in different places with code that worked in ASP.NET 3.5.
- Using the ISerializable interface, as shown above
- During compilation when the web controls assembly also contain ControlDesigner code.
It started happening for me when I added the AllowPartiallyTrustedCallersAttribute to my web controls assembly.
It is due to the new Security-Transparent Code, Level 2 features of ASP.NET 2.
Read its documentation to better learn what it does. For me, my goal was to avoid it.
The solution was to add the new SecurityRulesAttribute to your assembly, in the AssemblyInfo.cs/vb file.
This attribute turns off the features of Security-Transparent Code, Level 2.
Update Dec 1, 2009
Here is another error message that I encountered which is resolved the same way. It appears as a compiler error message.
Inheritance security rules violated by type: 'Class'. Derived types must either match the security accessibility of the base type or be less accessible.