CAS Permissions for Plugins in .net 4.0
Jun/28/2010
For the .net 4.0 release, Microsoft has introduces
some changes to the the way code security is treated. A summary and explanation
of the changes can be found at Security Changes in the .NET Framework 4 (http://msdn.microsoft.com/en-us/library/dd233103.aspx ).
In the .NET Framework 4, machine-wide security
policy is turned off by default. Applications that are not hosted (that is,
applications that are executed through Windows Explorer or from a command
prompt) now run as full trust. However, if the user's permissions have been
modified from the default settings, it is possible for a
System.TypeLoadException to be raised when Tradepoint is loading plugins. The
exception message would be similar to the following:
Exception:
System.TypeLoadException: Inheritance security rules violated by type: '{name of
the class without sufficient CAS rights}'. Derived types must either match the
security accessibility of the base type or be less
accessible.
To relsolve this issue the security level for the plugin
should be specified in the AssemblyInfo.cs for the assembly causing the
exception and any assembly dependant upon it. To specify the the security level
the following declaration can be used:
[assembly:
System.Security.SecurityRules(System.Security.SecurityRuleSet.Level2,
SkipVerificationInFullTrust = true)]
This affects assemblies that have been complied against
the .net 4.0 framework and higher.