This project is read-only.

"Inheritance security rules violated while overriding member: 'PublicDomain.ReadOnlyDictionary`2<TKey


Problem when moving to the .Net Framework 4.5. Full error is:

{"Inheritance security rules violated while overriding member: 'PublicDomain.ReadOnlyDictionary2<TKey,TValue>.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.":


andyrivera255 wrote Oct 1, 2013 at 1:54 AM

Here is the solution:
  1. Open ReadOnlyDictionary.cs and scroll to 400 (it says public void GetObjectData) it needs the following added right above: [System.Security.SecuritySafeCritical]
Here are more details about the fix from Microsoft:

andyrivera255 wrote Oct 15, 2013 at 2:20 AM

Well this broke again when I moved to framework 4.5 and it seems that marking the whole assembly to use the old security rules will be better. So you can go to readonlydictionary.cs and add the line right before the namespace line (after the using, before the "namespace PublicDomain"
[assembly: SecurityRules(SecurityRuleSet.Level1)]

More info here: