【问题标题】:Could not load file or assembly Temporary ASP.NET Files无法加载文件或程序集临时 ASP.NET 文件
【发布时间】:2012-11-11 14:09:44
【问题描述】:

我正在用 C# 开发一个 aps.net 网站,我正在使用框架 4。创建一个新的网站项目后,我尝试运行该项目。但我收到以下错误

Could not load file or assembly 'file:///C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\myfirst\159977c5\b9e740fc\App_global.asax.yfqtni9g.dll' or one of its dependencies. The system cannot find the file specified.

我已经浏览了以下链接 [并且都谈到了对文件夹的访问],但这对我没有帮助 :(

Could not load file or assembly 'file:///C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\ asp.net vs2010 ASP.NET corrupt assembly "Could not load file or assembly App_Web_*" http://web.archive.org/web/20101023213019/http://www.yetanotherdeveloper.com/post/2008/08/10/Could-not-load-file-or-assembly-App_Web.aspx

我检查并授予“临时 ASP.NET 文件”及其用户用户组的子文件夹和文件的完全访问权限。

程序集负载跟踪

警告:程序集绑定日志记录已关闭。 要启用程序集绑定失败日志记录,请将注册表值 [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) 设置为 1。 注意:有一些与程序集绑定失败日志相关的性能损失。 要关闭此功能,请删除注册表值 [HKLM\Software\Microsoft\Fusion!EnableLog]。

堆栈跟踪

[FileNotFoundException: Could not load file or assembly 'file:///C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\myfirst\4ff7194b\2da62764\App_global.asax.h-eem9xt.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, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +39
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +132
System.Reflection.Assembly.Load(AssemblyName assemblyRef, Evidence assemblySecurity) +28
System.CodeDom.Compiler.CompilerResults.get_CompiledAssembly() +93
System.Web.Compilation.BuildProvider.CreateBuildResult(CompilerResults results) +60
System.Web.Compilation.BuildProvider.GetBuildResult(CompilerResults results) +16
System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp) +9118863
System.Web.Compilation.BuildManager.CompileGlobalAsax() +44
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +265

[HttpException (0x80004005): Could not load file or assembly 'file:///C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\myfirst\4ff7194b\2da62764\App_global.asax.h-eem9xt.dll' or one of its dependencies. The system cannot find the file specified.]
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) +691

[HttpException (0x80004005): Could not load file or assembly 'file:///C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\myfirst\4ff7194b\2da62764\App_global.asax.h-eem9xt.dll' or one of its dependencies. The system cannot find the file specified.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9090876
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +258

如果这是一个重复的问题,请给我一个链接

感谢您的建议。

我得到的日志如下

手术成功。 绑定结果:hr = 0x0。操作成功完成。 从以下位置加载的程序集管理器:C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll 在可执行文件 C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe 下运行 --- 详细的错误日志如下。 === 预绑定状态信息 === 日志:用户 = John-PC\John 日志:DisplayName = Microsoft.VisualStudio.ComponentModelHost,版本 = 10.0.0.0,文化 = 中性,PublicKeyToken = b03f5f7f11d50a3a (完全指定) 日志:Appbase = file:///G:/WorkShop/HTML-CSS/ASP/MyFirst/ 日志:初始 PrivatePath = G:\WorkShop\HTML-CSS\ASP\MyFirst\bin 日志:动态基础 = C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\myfirst\159977c5 日志:缓存基础 = C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\myfirst\159977c5 日志:AppName = b9e740fc 调用程序集:(未知)。 === LOG:此绑定在默认加载上下文中开始。 LOG:使用应用程序配置文件:G:\WorkShop\HTML-CSS\ASP\MyFirst\web.config LOG:使用主机配置文件: LOG:使用 C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config 中的机器配置文件。 日志:通过查看 GAC 找到程序集。 LOG:绑定成功。从 C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.VisualStudio.ComponentModelHost\v4.0_10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.ComponentModelHost.dll 返回程序集。 LOG:程序集在默认加载上下文中加载。

我无法追踪任何错误。请帮帮我....

【问题讨论】:

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


【解决方案1】:

进入注册表并输入

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion]
"EnableLog"=dword:00000001
"LogFailures"=dword:00000001
"LogPath"="c:\\temp\\fusionLog"

对于加载的程序集,您将在 c:\temp\fusionLog 中找到一个日志

在那里你会发现缺少什么依赖。

【讨论】:

  • 嗨彼得,我不知道如何添加你提到的三个注册表。请帮我 。我在 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion] 目录中
  • 我做到了。右键单击-> 新建-> Dword。
  • 之后不要忘记禁用/删除融合日志。它将用日志文件填满磁盘并降低性能。
【解决方案2】:

我认为你有类似的问题: Could not load file or assembly 'file:///C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\ asp.net vs2010

接受的答案是:

尝试执行完整的解决方案构建。如果这不起作用,请单击 构建 -> 清洁解决方案。如果错误仍然存​​在,请删除中的所有内容 C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\parktms 文件夹并重复。

【讨论】:

  • HI Sarrus,我把上面的链接放在我的问题本身中。我删除了 Temporary ASP.NET Files 文件夹中的所有内容。我仍然遇到同样的错误。
  • 我进行了重建并重新发布,但并没有解决这个问题,但是清理然后重新发布到服务器确实可以。
【解决方案3】:

其中一个解决方案是从临时 asp.net 文件夹中删除那些对我有用的文件。

【讨论】:

  • 嗨 Sumant,我删除了框架目录中的 Temp 目录iteslf,所以现在我从 Temp 文件中得到了相同的错误,如下所示:“错误 1 ​​无法加载文件或程序集'file:/// C:\Users\John\AppData\Local\Temp\Temporary ASP.NET Files\myfirst\159977c5\b9e740fc\App_global.asax.r8qranjn.dll' 或其依赖项之一。系统找不到指定的文件。”跨度>
  • 当我关闭 Visual Studio 并停止我的 IIS 网站时,这对我有用。
  • @CiaranGallagher 你的小费帮助了我。我只是停止然后启动 IIS,错误就消失了。
【解决方案4】:

我在尝试开始性能测试后遇到了类似的问题。 我在web.config 中删除了system.web > compilation 元素中的assemblyPostProcessorType 属性,它再次起作用了。

 <system.web>
<compilation debug="false" targetFramework="4.5.1"  
            assemblyPostProcessorType="Microsoft.VisualStudio.Enterprise.Common.AspPerformanceInstrumenter, Microsoft.VisualStudio.Enterprise.AspNetHelper, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</system.web>

【讨论】:

  • web.config 文件在哪里?
【解决方案5】:

在部署 ASP.NET MVC 项目时,我在 Visual Studio 应用程序属性中重命名了其中一个项目的 DLL(程序集名称)。

在 ASP.NET MVC 项目的 Views 文件夹内有一个 Web.config 文件。这个Web.config 文件有以下razor 部分,我们可以在其中列出程序集,以便在Razor 视图文件中提供良好的IntelliSense 支持:

  <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <namespaces>
        <add namespace="VizionLogs.LogRepository" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization"/>
        <add namespace="System.Web.Routing" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>

我的问题:我将项目程序集从 VizionLogs.LogRepository 重命名为 ITVizion.VizionLogs.LogRepository 并忘记在 Web.config 文件中重命名它。这导致 ASP.NET Temp 文件夹错误告诉我找不到VizionLogs.LogRepository。我花了一些时间才弄清楚发生了什么以及错误在哪里...... :)

【讨论】:

    【解决方案6】:

    如果您使用 Visual Studio 性能工具,那么 Visual Studio 可能会在您的 web.config appsettings 部分中留下一个键。它会导致加载 32 位库,如果您的应用程序以 64 位模式加载,则该库将无法工作。

    检查以下内容并将其删除:

    <add key="Microsoft.VisualStudio.Enterprise.AspNetHelper.VsInstrLocation" value="C:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Performance Tools\vsinstr.exe"/>
    

    【讨论】:

      【解决方案7】:

      我有同样的问题。我只是通过改变来解决它 在 web.config -> system.web -> 编译 -> debug="false" 上。 然后就可以正常使用了

      【讨论】:

        【解决方案8】:

        从下面的文件夹中删除相应文件夹中的临时项目文件(如 for .net 4)将解决此问题。

        “C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files”

        也可以参考这个答案。

        Answered by Tommy

        【讨论】:

          【解决方案9】:

          从 web.config 中删除以下行将解决您的错误。

          <compilers>
                <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
                <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
              </compilers>
            </system.codedom>
          

          【讨论】:

            【解决方案10】:

            请备份并删除文件夹 myfirst\159977c5\b9e740fc\App_global.asax.yfqtni9g.dll'

            【讨论】:

              【解决方案11】:

              删除 (web.config) 块内的内容对我来说适用于类似的问题。

              a) 下面描述了为什么应该删除它
              What exactly does <system.codedom>/<compilers> do in web.config in MVC 5?

              以下来自 microsoft 的附加文章有助于理解该概念

              https://docs.microsoft.com/en-us/previous-versions/ms366723(v=vs.140)?redirectedfrom=MSDN

              编译文件夹位置

              默认情况下,当您编译 Web 应用程序时,编译后的代码将放置在 Temporary ASP.NET Files 文件夹中。此文件夹是您安装 .NET 框架的位置的子目录

              除此之外,另一篇文章建议仔细检查目标框架和安装的框架

              【讨论】:

                【解决方案12】:

                就我而言,我在 web.config 中找到 bin 文件夹,如下所示:

                <appSettings>
                      <add key="webSettingFolder" value="C:\Users\ali eshghi\source\repos\SalesWebApiDotNetFramWork\SalesWebApiDotNetFramWork\bin\"/>
                  </appSettings>
                

                之后错误消失了。

                【讨论】:

                  猜你喜欢
                  • 1970-01-01
                  • 1970-01-01
                  • 1970-01-01
                  • 1970-01-01
                  • 2020-08-17
                  相关资源
                  最近更新 更多