When building ASP.NET website with Visual Studio 2008 Beta 2 or Visual Web Developer 2008 Express, a new entry in the applications web.config configuration file is inserted. This is done when the user creates a new project, or migrates an existing website to use .NET Framework 3.5.

An example of the configuration entry is given below:

<system.codedom>
   <compilers>
      <compiler language="c#;cs;csharp" extension=".cs"
         type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
         warningLevel="4" compilerOptions="/warnaserror-">
      <providerOption name="CompilerVersion" value="v3.5"/>
      </compiler>
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
         type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
         compilerOptions="/optioninfer+">
      <providerOption name="CompilerVersion" value="v3.5"/>
      </compiler>
   </compilers>
</system.codedom>

Compiler Options
Compiler Options


Since The compilerOptions setting is not allowed in medium trust or a partial trust, when this website runs in medium trust or any partial trust setting, ASP.NET will raise the following error

“the current trust level does not allow use of the ‘compilerOptions’ attribute”.

The current trust level does not allow use of the 'compilerOptions' attribute
The current trust level does not allow use of the 'compilerOptions' attribute


Solution 1:


To solve the problem, you have to remove the compilerOptions setting and the warningLevel setting, from configuration section in web.config file after creating or migrating the application. After the change, the settings should appear as follows:

<system.codedom>
   <compilers>
      <compiler language="c#;cs;csharp" extension=".cs"
         type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <providerOption name="CompilerVersion" value="v3.5"/>
      </compiler>
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
         type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <providerOption name="CompilerVersion" value="v3.5"/>
      </compiler>
   </compilers>
</system.codedom>

Solution 2:


To solve the problem open the web.config file and add/change the trust level as follows:

<system.web>   
   <trust level="Full"/>
</system.web>

Finally, rebuild the project.

Want automatic updates? Subscribe to our RSS feed or
Get Email Updates sent directly to your inbox!

Currently rated 5.0 by 5 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Comments

Add comment




(Will not be displayed!)








SponsoredTweets referral badge
Free CMS