Security accessibility of the overriding method must match

Problem

You get this error when running your application.

Inheritance security rules violated while overriding member: MyApp4.Business.OrdersTable.GetObjectData. Security accessibility of the overriding method must match the security accessibility of the method being overridden

Your application is a Website using the .net framework 4.0 or 4.5 and you are running in medium trust.

Solution

Use the application wizard to change to a Web Applilcation. Using medium trust requires a web application, which will add the following code to all AssemblyInfo.cs (.vb) files in your application.

Visual Basic .NET:

Imports System.Security

 

<Assembly: SecurityRules(SecurityRuleSet.Level1)>

C#:

using System.Security;

 

[assembly: SecurityRules(SecurityRuleSet.Level1)]

See Also

Part IX:  Troubleshooting Applications

Application Will Not Run

Application Runs But No Data is Displayed

Application Error Messages