Search code examples
asp.net.netnant

Has anyone encountered: "Could not load file or assembly 'aspnet_compiler... Failed to grant permission to execute"?


I am encountering a strange build issue in .NET 3.5. The compiler is crashing when it attempts to build a Web Deployment Project.

C:\Program Files\MSBuild\Microsoft\WebDeployment\v9.0\Microsoft.WebDeployment.targets(531,9): error MSB6006: "aspnet_compiler.exe" exited with code -532459699.

Which leads to:

Could not load file or assembly 'aspnet_compiler, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Failed to grant permission to execute. (Exception from HRESULT: 0x80131418)

That section of Microsoft.WebDeployment.targets is this:

<AspNetCompiler 
      PhysicalPath="$(_AspNetCompilerSourceWebPath)"
      TargetPath="$(TempBuildDir)"
      VirtualPath="$(_AspNetCompilerVirtualPath)"
      Force="$(_Force)"
      Debug="$(DebugSymbols)"
      Updateable="$(EnableUpdateable)" 
      KeyFile="$(_FullKeyFile)" 
      KeyContainer="$(_AspNetCompilerKeyContainer)"
      DelaySign="$(DelaySign)" 
      AllowPartiallyTrustedCallers="$(AllowPartiallyTrustedCallers)" 
      FixedNames="$(_AspNetCompilerFixedNames)" 
      Clean="$(Clean)"
      MetabasePath="$(_AspNetCompilerMetabasePath)"
/>

If I try:

aspnet_compiler.exe -errorstack -v /MyProject -p C:\MyProject -f -c -d .\TempBuildDir\

I get:

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'aspnet_compiler, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Failed to grant permission to execute. (Exception from HRESULT: 0x80131418)

File name: 'aspnet_compiler, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ---> System.Security.XmlSyntaxException: Invalid syntax.

I could build fine until I made a small code change. I've reverted the change, but I continue to encounter this error. Other team members can build the exact same source.

Things I've Tried

  • Reinstalling VS
  • Reinstalling Web Deployment Projects addin
  • Restarting
  • Building with nant
  • Building in VS
  • Building from the command line with aspnet_compiler.exe

Has anyone encountered this type of error before? My next step is to reformat, unless I can find something else to try.


Solution

  • I was finally able to build after running a full build in nant with:

    nant build
    

    I thought I tried this before. Anyway, it works now--no thanks to the error message. I imagine that my nant config for MyProject is missing a dependency, or something.