目录' / website / App_Code /'是不允许的,因为应用程序是预编译的

时间:2014-06-30 07:25:08

标签: c#-4.0 asp.net-4.0 precompiled

如何解决运行预编译Web应用时遇到的以下问题?

Server Error in '/CRM' Application.
    The directory '/CRM/App_Code/' is not allowed because the application is precompiled.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Web.HttpException: The directory '/CRM/App_Code/' is not allowed because the application is precompiled.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:


    [HttpException (0x80004005): The directory '/CRM/App_Code/' is not allowed because the application is precompiled.]
       System.Web.Compilation.CodeDirectoryCompiler.GetCodeDirectoryAssembly(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories, Boolean isDirectoryAllowed) +8777420
       System.Web.Compilation.BuildManager.CompileCodeDirectory(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories) +125
       System.Web.Compilation.BuildManager.CompileCodeDirectories() +387
       System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +248

    [HttpException (0x80004005): The directory '/CRM/App_Code/' is not allowed because the application is precompiled.]
       System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +62
       System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +421
       System.Web.Compilation.BuildManager.CallAppInitializeMethod() +31
       System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +605

    [HttpException (0x80004005): The directory '/CRM/App_Code/' is not allowed because the application is precompiled.]
       System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8946484
       System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
       System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +258


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

4 个答案:

答案 0 :(得分:27)

根据您的情况,有三种可能的情况:

请参阅此链接http://www.beansoftware.com/ASP.NET-FAQ/Directory-App_Code-Not-Allowed.aspx

基本上,如果你预先编译了你的应用程序,那么就不应该成为App_Code文件夹了。如果您以后添加它,则应将其删除。

OR

可能是某种方式,precompiled.config文件已经投入生产。删除该文件应解决App_Code目录错误。

答案 1 :(得分:12)

删除" precompiledApp.config"文件应解决您的问题。

答案 2 :(得分:1)

在我的情况下,我错误地,强制发布一个类,这导致了这个问题。

解决方案是对违规类进行更新,然后再次使用“从目标站点删除未使用的文件”选项发布。 (在发布模式选项下)

答案 3 :(得分:1)

就我而言,我使用“ ASPX文件是可更新的”选项选中的。我猜我的网站运行的IIS不喜欢这样。

将“ ASPX文件可更新”选项重新编译为“打开”后,问题就消失了。