首页 > 解决方案 > 无法加载文件或程序集

问题描述

当我在网页第二次向我显示此内容时尝试构建我的网站时,我遇到了以下问题。我寻求解决方案,但我还没有得到它。当我第一次加载项目时,所有功能都运行良好,问题是当我关闭计算机并第二次启动项目时。

有错误的图像

Server Error in '/' Application.
Could not load file or assembly 'file:///C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\8414c445\dc4fe894\App_global.asax.7hmxt1lb.dll' or one of its dependencies. The system cannot find the file specified.
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.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\8414c445\dc4fe894\App_global.asax.7hmxt1lb.dll' or one of its dependencies. The system cannot find the file specified.

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.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'file:///C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\8414c445\dc4fe894\App_global.asax.7hmxt1lb.dll' could not be loaded.


WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Stack Trace:


[FileNotFoundException: Could not load file or assembly 'file:///C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\8414c445\dc4fe894\App_global.asax.7hmxt1lb.dll' or one of its dependencies. The system cannot find the file specified.]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +232
   System.Reflection.Assembly.Load(AssemblyName assemblyRef, Evidence assemblySecurity) +62
   System.CodeDom.Compiler.CompilerResults.get_CompiledAssembly() +119
   System.Web.Compilation.BuildProvider.CreateBuildResult(CompilerResults results) +74
   System.Web.Compilation.BuildProvider.GetBuildResult(CompilerResults results) +22
   System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp) +12028905
   System.Web.Compilation.BuildManager.CompileGlobalAsax() +52
   System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +341

[HttpException (0x80004005): Could not load file or assembly 'file:///C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\8414c445\dc4fe894\App_global.asax.7hmxt1lb.dll' or one of its dependencies. The system cannot find the file specified.]
   System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +76
   System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +631
   System.Web.Compilation.BuildManager.CallAppInitializeMethod() +38
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +758

[HttpException (0x80004005): Could not load file or assembly 'file:///C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\8414c445\dc4fe894\App_global.asax.7hmxt1lb.dll' or one of its dependencies. The system cannot find the file specified.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +552
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +122
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +737

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

标签: c#asp.netiisload.net-assembly

解决方案


when I turned off my computer and I start with the project by the second time

我怀疑你把它关掉了——但是很多文件没有正确写回磁盘....

指出

错误出现在Temporary ASP.NET Files目录上 - asp.netautomatically生成文件的目录 - 这与您的代码无关(至少在大多数情况下) - 但问题出在 asp.net 编译器上。

总体思路

停止您使用的程序并清除缓存和临时文件,然后再次运行它们。

我遵循的步骤

我建议执行什么步骤并清除缓存,以便 IIS/asp.net/cs 重新编译项目。 停止制作临时文件的程序

  1. 检查 C 盘是否有可用空间。
  2. 关闭所有 Visual Studio 程序
  3. 打开“服务”并停止 IIS“万维网发布服务”

现在我们已经停止了主编译器,我们去清除所有可能的缓存和临时文件。对于删除使用程序(如总指挥官)也可以查看隐藏文件

  1. 清除 asp.net 临时目录->C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\此处的所有文件和目录以及Temporary ASP.NET Files您计算机上存在的所有内容取决于您如何运行项目 32/64 位-以及您使用的版本...

  2. 清除临时 windows 临时目录。键入cd %temp%并在那里删除所有文件 - 留下您无法删除的锁定文件......

  3. 清除您可以在其上找到的其他临时系统 Windows 目录c:\windows\temp

  4. (可选)清除.vs项目目录中的隐藏缓存目录 - 仅当您在 Visual Studio 和项目中遇到问题和延迟时才会这样做

现在放开并再次运行程序

  1. 再次运行“服务”并启动 IIS“万维网发布服务”
  2. 运行视觉工作室,给他一秒钟重新编译需要的东西......

现在你的问题必须得到解决。为避免文件损坏,请检查您的计算机是否有足够的可用空间,检查系统上的日期时间,不要强制关闭系统。还要检查您的硬盘是否有错误 - 打开命令提示符窗口cmd并运行chkdsk c: /f检查并修复任何错误。

关于临时目录

每台计算机上的临时目录都不相同。您可以在控制面板 | 上找到它们。系统 | 系统属性 | 环境变量-> 在那里寻找TEMPand TMP。当您键入时,cd %temp%您会转到临时目录,但是许多程序在不同的帐户下运行,例如 windows 有该c:/windows/temp/目录可供使用。

关于 asp.net 临时目录。此目录默认c:\Windows\Microsoft.NET\Framework64\为 64 位,您可以在其中找到版本,然后找到Temporary ASP.NET Files. 这是您可以在web.config您的网络应用程序上更改的内容...

其他可能的原因

检查您的事件查看器,看看是否有任何行表明编译器崩溃!

Application: csc.exe Framework Version: v###### Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.FileNotFoundException at Microsoft.CodeAnalysis.CSharp.CommandLine.Program.Main(System.String[])

在这种情况下,您可能在全局调用中使用了任何非 asp.net net 函数,或者任何会导致编译器挂起的错误...还要检查您的 web.config 中关于编译器的部分是否正确 - 这是一个示例:

  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" 
      type="Microsoft.CSharp.CSharpCodeProvider, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
        <providerOption name="CompilerVersion" value="v4.0"/>
        <providerOption name="WarnAsError" value="false"/>
      </compiler>
    </compilers>
  </system.codedom>

推荐阅读