Upgrading Orchard and security exceptions

Tags: orchard, security, upgrade, english

In some cases, when upgrading your Orchard instance, you may see something like this in your logs and wonder, “what the hell is going on??”:

Orchard.Environment.Extensions.ExtensionManager - Error loading extension 'XXX’
System.TypeLoadException: Inheritance security rules violated by type: ‘XXX’. Derived types must either match the security accessibility of the base type or be less accessible.

This is because of some changes to assembly-level security in Orchard, which makes using the assembly attribute

[assembly: SecurityTransparent]

to cause trouble. Some older modules had that attribute declared inside the /Properties/AssemblyInfo.cs file.

The solution is to change the line shown above to:

[assembly: SecurityRules(SecurityRuleSet.Level2)]

to enforce Level 2 security in a given module. Removing that line would also help.

You can read more about security in .NET framework on MSDN.

1 Comment