0

I'm getting this error from Nhibernate 4.1.0 in release mode with c# ASP.NET application on .NET 4.5.1:

Inheritance security rules violated while overriding member: 'Antlr.Runtime.RecognitionException.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.

Being Antl3 an included dll I can't figure out what is the problem

Andrea Giovacchini
  • 5,027
  • 3
  • 21
  • 23

2 Answers2

0

This stackoverflow post pointed me in the right direction.

I needed to have an Antl3 version which had GetObjectData marked with SecurityCriticalAttribute and that was clearly not the version shipped with NHibernate 4.1.0 sources, so I got Antl3 sources from here and looked at RecognitionException under Antl3.Runtime.net40-client and have seen it was correct:

        [SecurityCritical]
    public override void GetObjectData(SerializationInfo info, StreamingContext context)
    {

So I've bult it, replaced the produced dll in the NHibernate-4.1.0.GA-src\lib\net folder and et voila, now the application runs fine

Community
  • 1
  • 1
Andrea Giovacchini
  • 5,027
  • 3
  • 21
  • 23
0

This is most likely due to the fact that your application demands "more trust". You can change the trust level for your application by adding <trust level="Full" /> in your web.config (inside system.web).

<system.web>
    <trust level="Full" />
<system.web>

More about ASP.NET Trust levels can be found here.

James Poulose
  • 3,569
  • 2
  • 34
  • 39