ASPNETCompiler Error - System.Web.AspNetHostingPermission, System

Answered ASPNETCompiler Error - System.Web.AspNetHostingPermission, System

  • Friday, November 18, 2005 3:04 AM
     
     
    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.

All Replies

  • Friday, November 18, 2005 5:35 AM
    Moderator
     
     Answered
    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
  • Monday, November 21, 2005 5:52 PM
     
     
    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.
  • Tuesday, November 22, 2005 11:30 PM
     
     
    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
  • Monday, November 28, 2005 5:15 PM
     
     
    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.)
  • Monday, November 28, 2005 5:19 PM
     
     
    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.
  • Monday, November 28, 2005 5:45 PM
    Moderator
     
     
    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
  • Monday, November 28, 2005 6:02 PM
    Moderator
     
     
    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
  • Monday, November 28, 2005 7:53 PM
     
     

    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

  • Monday, November 28, 2005 9:57 PM
     
     
    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.

  • Wednesday, November 30, 2005 4:33 AM
     
     Answered
    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!
  • Wednesday, November 30, 2005 5:21 PM
     
     Answered
    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.

  • Wednesday, November 30, 2005 8:54 PM
     
     

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

    Thanks!

  • Thursday, December 01, 2005 10:13 PM
     
     
    Try increasing the .NET framework assembly trust for the zone that you're referencing any DLL's from.  That's probably the issue.
  • Friday, February 23, 2007 11:05 AM
     
     

    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

  • Friday, February 23, 2007 4:52 PM
     
     

     

    Check out this blog post on using Caspol to fully trust a share:

    http://blogs.msdn.com/shawnfa/archive/2004/12/30/344554.aspx

     

  • Friday, February 23, 2007 5:37 PM
     
     
    Is this a web applications project thing? I have 2 on one server- and one I could build no problem, but on the other I am now getting this error. What gives?
  • Thursday, August 23, 2007 7:33 PM
     
     
    And to save everyone a few minutes, here's the KB article that will guide you through the process of granting FullTrust right to the remote share: http://support.microsoft.com/kb/320268
  • Thursday, February 07, 2008 6:57 PM
     
     Proposed Answer
    Hi,

    This solution has not worked at all for me.  I used a thrid party software to generate ans ASP.NET application (Iron Speed).  Following their production procedure, I copied the app to the produciton server minus the unnecessary files. 

    I do nto ahve a UNC connection; I have full trust permissions; I am at a loss.  The web app works fine on my local machine, but not in production.  I am at a loss.  I get the same message veryone else is getting; and the iron speed people say it is my environment.


    • Proposed As Answer by abhishek556 Monday, November 22, 2010 6:55 PM
    •  
  • Monday, February 21, 2011 7:38 PM
     
     
    In our particular case we got the error when trying to load web content under IIS 7 where each file in the solution had an alternate data stream with zone information in it. We downloaded streams.exe from www.sysinternals.com and ran it against all the content to remove the stream and the site loaded without issue. This might be slightly different to your issue but produced the same error so posting this information in case it can help someone else.