ASPNETCompiler Error - System.Web.AspNetHostingPermission, System

We are getting the following error in our automated build process.

AspNetCompiler: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v /PreCompiledWeb -p "Web Sites\Campaigns\\" -u -f -d PreCompiledWeb\ 
 AspNetCompiler: : ERROR /PreCompiledWeb/Controls/SignInOptions.ascx(4,0): Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
  Finished Task AspNetCompilerDone executing task "AspNetCompiler" -- FAILED.

We've added the following security attributes to the offending control - but this has not fixed the error.

[AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Unrestricted)]

[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Unrestricted)]


Any help would be greatly appreciated.


Answer this question

ASPNETCompiler Error - System.Web.AspNetHostingPermission, System

  • DW5000

    Hello,

    Thank you for taking the time to respond to our post.

    We are using Visual Studio 2005 Team Suite Trial Version.
    VS 2005 Version 8.0.50727.42
    .NET Framework Version 2.0.50727

    1. Note that we do not have this error when we run aspnet_compiler dircectly from the command line against our source code.  We only get this error when aspnet_compiler runs from within our MSBuild script.  (The parameters passed to aspnet_compiler are exactly the same)

    below is from our build script -- we are using the built-in MSBuild task and passing our solution file to the task.  Therefore, in order to add -errorstak when calling aspnet_compiler I will have to go muck with one of the target files that ships with Visual Studio.  I will try this and post the stack trace if I can get it.

    <!-- Compile Code -->

    <Target Name="Build">

    <MSBuild Projects="$(BuildFolder)\Foo.Company.Marketing.sln" />

    <OnError ExecuteTargets="ReportFailure"/>

    </Target>

    2. There is no other trust level set underneath the machine level.  We are not trying to intentionally run the app under partial trust.  The trust level is set to Full at the machine level.

    3. The referenced dll is in the bin and we have signed it with a strong name (but we only signed it after we encountered this problem thinking that it might fix it which it did not)

    4. Yes the user control is working fine in the source application.

    This is a very basic app.


  • briggins5

    hi!

    Can you please let me know what problems you had creating an account on the ASP.NET forums   You can send me an email at plepage@microsoft.com.

    I'll get someone to answer your question asap!

    PEte

  • MikaelN

    The AspNetCompiler is separate from MSBuild. The folks over in the ASP.NET forums will be able to assist you. You can find more info on the forums at http://www.asp.net/welcome.aspx tabindex=1&tabid=39.
     
    Neil


  • Macrap

    Thank you Qing!!!

    We were running our build process in a UNC share.  I used the .NET Framework Configuration Tool to grant FullTrust permission to this share and now everything works just fine.


  • Kishan Sanji

    Were you able to find an ACTUAL solution to this We have a website that has been working just fine under 1.1 but are now trying to migrate it to 2.0 with this same problem. Thanks
  • Kjell Arne

    I know it's frustrating, but because this is a problem with the ASP.NET compiler the question really needs to go to the ASP.NET team. The MSBuild team doesn't own or understand the compiler at all.

    I'll forward this thread to our internal ASP.NET customer response team and hopefully someone can jump in. In the mean time do try and post over at forums.asp.net. They have a special forum just for Visual Studio 2005 integration discussion.

    Neil

  • Maciej Boniecki

    After further investigation we have found that the error actually occurs when the ASPParse is parsing .ASCX files that contain references to another assembly within the solution. 

    What is interesting is that if we simply run aspnet_compiler against the same source folder from the command line (with the exact same parameters that the MSBuild script generates) there are no errors.  This error only occurs when we run the MSBuild script.

    We believe that the security policy is set up correctly on the build server and that we shouldn't be experiencing this security problem.

  • RobertNet

    Hello mtobin & Qing

    I'm getting the same error, but I haven't found how to grant fulltrust to a share. I've just succeded in granting permission levels to assemblies. When I try to set it to a share it tells me that it can't load the assembly.

    Should I grant the fulltrust permission to the dlls used by my web pages or something like that

    Sorry my unknowledge about security. I'm getting on it nowadays.

    Thank you in advance


  • SFdesign

    Unfortunately, we haven't found a solution yet.  I couldn't even successfully create an account on the asp.net site so I was unable to post the question there.
  • Will Pearson - MVP

    Hi mtobin,

    I'm from ASP.Net team in Microsoft. Have some questions to drill down the issue:
    1. Would you show us the stack for the error You may use -errorstack when calling aspnet_compiler.
    2. Is there any trust level set under machine level  Are you intentionally want to run the app under partial trust
    3. Where is the referenced dll GAC or bin If none of these, how do you set up binding
    4. Is this particular usercontrol working in the source application before precompilation  

    Thanks,
    Qing


  • Ensign Joe

    Excellent! Please let us know if you run into other issues. Use http://forums.asp.net/ will get a faster response.

    Thanks!


  • aruyp

    Try increasing the .NET framework assembly trust for the zone that you're referencing any DLL's from.  That's probably the issue.
  • misterEd

    Did you run aspnet_compiler from the same location as you run MSBuild Same path and same machine Is there any UNC share invloved when you saw the error If so, you might need to run caspol.exe (in the framework installation location) to grant permission to the share.

    Thanks!

  • katrien

    It seems the problem is caused by VS.NET 2005 and not necessarily ASP.NET 2.0. Any solutions yet (ie: posts that don't go to a "welcome" page on asp.net, as I haven't found the answer there yet either.)
  • ASPNETCompiler Error - System.Web.AspNetHostingPermission, System