Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1185
Sample code in a Medium Trust environment
posted

Can I strongly suggest you amend the official Asp.NET examples to include changes making it easier to cut/paste into applications that must run in a Hosted/Medium trust environment. I just wasted a day try to track down a a security error:

Security Exception
Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Configuration.ConfigurationPermission, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed.

Eventually, I found that it was caused by the following entries in the web.config file:

<section name="infragistics" type="Infragistics.Guidance.Web.Configuration.StyleConfigurationSection, Infragistics.Guidance.Web, Version=1.0.0.1, Culture=neutral" />
<section name="infragistics.web" type="System.Configuration.SingleTagSectionHandler, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

Now I understand why these are present, and the code that drives them (and I want to use it), however I DO NOT understand why you left off a critical piece:

<section name="infragistics" type="Infragistics.Guidance.Web.Configuration.StyleConfigurationSection, Infragistics.Guidance.Web, Version=1.0.0.1, Culture=neutral" requirePermission="false" />
<section name="infragistics.web" type="System.Configuration.SingleTagSectionHandler, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

This simple attribute ( requirePermission="false" ) is all that stands between this code working fine in a medium trust situation...sigh, and the error spat out by IIS isn't exactly helpful...sigh. The setting works fine in Full Trust scenarios too.

I applaud the attempt to make the sample code explore so many different areas - its been very useful to me so far. I just hope I don't run into any more of these obscure issues..sigh

I'm posting this so anyone else trying the same thing will find their solution quickly.