19

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

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

4

12 回答 12

25

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

 <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>
于 2013-10-29T20:04:09.173 回答
9

如果您使用 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"/>
于 2015-02-13T17:44:01.007 回答
4

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

于 2012-11-23T13:31:22.513 回答
3

从 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>
于 2019-12-05T06:17:05.730 回答
2

就我而言,在部署 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.LogRepositorytoITVizion.VizionLogs.LogRepository重命名并忘记在该Web.config文件中重命名它。这导致 ASP.NET Temp 文件夹错误告诉我找不到VizionLogs.LogRepository. 我花了一些时间来弄清楚发生了什么以及错误在哪里...... :)

于 2014-05-05T19:08:53.990 回答
2

我认为在这里你有类似的问题: 无法加载文件或程序集 '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 文件夹中的所有内容并重复。

于 2012-11-23T09:49:23.537 回答
1

转到注册表并输入

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

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

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

于 2012-11-23T08:22:45.420 回答
0

删除 (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 框架的位置的子目录

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

于 2020-02-14T15:28:58.037 回答
0

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

于 2017-12-04T14:00:32.377 回答
0

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

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

也可以参考这个答案。

汤米回答

于 2019-11-05T05:58:16.383 回答
0

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

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

之后错误消失了。

于 2020-08-29T09:50:43.520 回答
0

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

于 2020-01-16T07:41:12.020 回答