繁体   English   中英

无法加载文件或程序集临时 ASP.NET 文件

[英]Could not load file or assembly Temporary ASP.NET Files

我正在用 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.

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

无法加载文件或程序集 'file:///C:\\WINDOWS\\Microsoft.NET\\Framework\\v4.0.30319\\asp.net vs2010

ASP.NET 损坏的程序集“无法加载文件或程序集 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 文件”及其子文件夹和用户用户组文件的完全访问权限。

装配负载跟踪

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].

堆栈跟踪

[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

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

感谢广告。

I got the Log as follows The operation was successful. Bind result: hr = 0x0. The operation completed successfully. Assembly manager loaded from: C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\clr.dll Running under executable C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\devenv.exe --- A detailed error log follows. === Pre-bind state information === LOG: User = John-PC\\John LOG: DisplayName = Microsoft.VisualStudio.ComponentModelHost, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (Fully-specified) LOG: Appbase = file:///G:/WorkShop/HTML-CSS/ASP/MyFirst/ LOG: Initial PrivatePath = G:\\WorkShop\\HTML-CSS\\ASP\\MyFirst\\bin LOG: Dynamic Base = C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\Temporary ASP.NET Files\\myfirst\\159977c5 LOG: Cache Base = C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\Temporary ASP.NET Files\\myfirst\\159977c5 LOG: AppName = b9e740fc Calling assembly : (Unknown). === LOG: This bind starts in default load context. LOG: Using application configuration file: G:\\WorkShop\\HTML-CSS\\ASP\\MyFirst\\web.config LOG: Using host configuration file: LOG: Using machine configuration file from C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\config\\machine.config. LOG: Found assembly by looking in the GAC. LOG: Binding succeeds. Returns assembly from C:\\Windows\\Microsoft.Net\\assembly\\GAC_MSIL\\Microsoft.VisualStudio.ComponentModelHost\\v4.0_10.0.0.0__b03f5f7f11d50a3a\\Microsoft.VisualStudio.ComponentModelHost.dll. LOG: Assembly is loaded in default load context.

 I got the Log as follows The operation was successful. Bind result: hr = 0x0. The operation completed successfully. Assembly manager loaded from: C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\clr.dll Running under executable C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\devenv.exe --- A detailed error log follows. === Pre-bind state information === LOG: User = John-PC\\John LOG: DisplayName = Microsoft.VisualStudio.ComponentModelHost, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (Fully-specified) LOG: Appbase = file:///G:/WorkShop/HTML-CSS/ASP/MyFirst/ LOG: Initial PrivatePath = G:\\WorkShop\\HTML-CSS\\ASP\\MyFirst\\bin LOG: Dynamic Base = C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\Temporary ASP.NET Files\\myfirst\\159977c5 LOG: Cache Base = C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\Temporary ASP.NET Files\\myfirst\\159977c5 LOG: AppName = b9e740fc Calling assembly : (Unknown). === LOG: This bind starts in default load context. LOG: Using application configuration file: G:\\WorkShop\\HTML-CSS\\ASP\\MyFirst\\web.config LOG: Using host configuration file: LOG: Using machine configuration file from C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\config\\machine.config. LOG: Found assembly by looking in the GAC. LOG: Binding succeeds. Returns assembly from C:\\Windows\\Microsoft.Net\\assembly\\GAC_MSIL\\Microsoft.VisualStudio.ComponentModelHost\\v4.0_10.0.0.0__b03f5f7f11d50a3a\\Microsoft.VisualStudio.ComponentModelHost.dll. LOG: Assembly is loaded in default load context.

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

尝试开始性能测试后,我遇到了类似的问题。 我在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>

如果您使用 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"/>

解决方案之一是从始终适用于我的临时 asp.net 文件夹中删除这些文件。

从 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>

在这里你有类似的问题,我认为: 无法加载文件或程序集 'file:///C:\\WINDOWS\\Microsoft.NET\\Framework\\v4.0.30319\\ asp.net vs2010

接受的答案是:

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

就我而言,在部署 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 我花了一些时间才弄清楚发生了什么以及错误在哪里...... :)

转到注册表并输入

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

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

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

我有同样的问题。 我只是通过更改 web.config -> system.web -> 编译 -> debug="false" 来解决它。 然后它工作正常

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

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

也可以参考这个答案。

汤米回答

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

删除 (web.config) 块内的内容对我有类似的问题。

a) 下面描述为什么你应该删除它
<system.codedom>/<compilers> 在 MVC 5 中的 web.config 中到底做了什么?

遵循微软的附加文章有助于理解这个概念

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

编译文件夹位置

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

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

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

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

之后错误消失了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM