.NET4 and a bad interaction with Medium Trust

Nov 29, 2011 at 8:58 PM

My production system is running in a medium trust environment.

I recently upgraded my environment to .NET4, I needed to take advantage of some new features.

I retargeted my project to .NET4 and downloaded the latest source (which is already targeted for .NET4, thank you thank you!)

When I deployed, my application started throwing exceptions with the error:

"Inheritance security rules violated by type: 'AjaxDataControls.GridViewDesigner'. Derived types must either match the security accessibility of the base type or be less accessible. ---> System.Web.HttpParseException: Inheritance security rules violated by type: 'AjaxDataControls.GridViewDesigner'. Derived types must either match the security accessibility of the base type or be less accessible."  ...

 

On my dev environment, which runs in full trust, there was no issue.  However, in production, running medium trust (and I cannot change that) I get the exception

 

I did some searching and came across this:

http://social.msdn.microsoft.com/Forums/en/vsto/thread/b84aad34-cef4-4045-9111-3fd3a66a5789

 

In there is the suggestion to add the following line to the AssemblyInfo.cs

[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]

I recompiled and life is good.  Anyone have thought on if this is a general problem or if this is specific to what I'm doing?

If it's general, the above line needs to be added.