Why do I get TypeLoadException when moving to .NET 4?
There have been some security changes in the .NET 4.0 Framework, so when moving a project to .NET 4.0 you may get the following exception:
TypeLoadException - Derived Types must either match the security accessibility of the base type or be less accessible.
There are two approaches to fixing this problem:
- If you are you using the SecurityTransparentAttribute in your project's AssemblyInfo.cs /vbfile you need to remove this attribute since it's now obsolete in the .NET 4 Framework.
- If this isn't the case, try adding the following attribute to your project's AssemblyInfo.cs/vb file to get past the exception:
[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]
For more information, check out this MSDN topic: http://msdn.microsoft.com/en-us/library/dd233102(VS.100).aspx
© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 08/25/10
Comment or report problem with topic
