C# 无法加载文件或程序集临时 ASP.NET 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13525211/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not load file or assembly Temporary ASP.NET Files
提问by new_programmer
I am developing a aps.net website in C# and I am using framework 4. After creating a new website project I tried to run the project. but I am getting the below error
我正在用 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\Temporary ASP.NET Files\myfirst\159977c5\b9e740fc\App_global.asax.yfqtni9g.dll' or one of its dependencies. The system cannot find the file specified. I already went through the below links [and all speaks about access to the folder], but it didn't help me :(
我已经浏览了以下链接 [并且都谈到了对文件夹的访问],但这对我没有帮助:(
Could not load file or assembly 'file:///C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\ asp.net vs2010无法加载文件或程序集 'file:///C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\asp.net vs2010ASP.NET corrupt assembly "Could not load file or assembly App_Web_*"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.aspxhttp://web.archive.org/web/20101023213019/http://www.yetanotherdeveloper.com/post/2008/08/10/Could-not-load-file-or-assembly-App_Web.aspxI checked and gave full access "Temporary ASP.NET Files" and to its sub folders and files for Users user-group.
我检查并授予了“临时 ASP.NET 文件”及其子文件夹和用户用户组文件的完全访问权限。
Assembly Load Trace
装配负载跟踪
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].
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\Framework\v4.0.30319\Temporary ASP.NET Files\myfirstff7194bda62764\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\myfirstff7194bda62764\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\myfirstff7194bda62764\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
Please give me a link if this is a repeated question
如果这是一个重复的问题,请给我一个链接
感谢广告。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\myfirst9977c5
LOG: Cache Base = C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\myfirst9977c5
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\myfirst9977c5
LOG: Cache Base = C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\myfirst9977c5
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 am not able to trace any error. Please help me....
我无法追踪任何错误。请帮我....
回答by pero
Go to Registry and enter
转到注册表并输入
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion]
"EnableLog"=dword:00000001
"LogFailures"=dword:00000001
"LogPath"="c:\temp\fusionLog"
For loaded assembly you will find a log in c:\temp\fusionLog
对于加载的程序集,您会在 c:\temp\fusionLog 中找到一个日志
There you will find what dependency is missing.
在那里您会发现缺少什么依赖项。
回答by Sarrus
Here you have similar problem I think: Could not load file or assembly 'file:///C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\ asp.net vs2010
在这里你有类似的问题,我认为: Could not load file or assembly 'file:///C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\ asp.net vs2010
accepted answer was:
接受的答案是:
Try performing a full solution build. If that doesn't work, click Build -> Clean Solution. If the error persists, delete everything in the C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\parktms folder and repeat.
尝试执行完整的解决方案构建。如果这不起作用,请单击 Build -> Clean Solution。如果错误仍然存在,请删除 C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\parktms 文件夹中的所有内容并重复。
回答by Sumant
One of the solution is to delete those files from temporary asp.net folder that always works for me.
解决方案之一是从始终适用于我的临时 asp.net 文件夹中删除这些文件。
回答by Jan Remunda
I had simmilar problem after i tried to start performance tests.
I removed assemblyPostProcessorType attribute in system.web> compilationelement in web.configand it worked again.
尝试开始性能测试后,我遇到了类似的问题。我删除了system.web> compilationelement in 中的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>
回答by Leniel Maccaferri
In my case while deploying an ASP.NET MVC project I renamed the DLL of one of the projects (the Assembly Name) in Visual Studio application properties.
就我而言,在部署 ASP.NET MVC 项目时,我在 Visual Studio 应用程序属性中重命名了其中一个项目(程序集名称)的 DLL。
Inside the Views folder of the ASP.NET MVC project sits a Web.configfile. This Web.configfile has the following razorsection where we can list assemblies for nice IntelliSense support in Razor view files:
在 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>
My problem: I renamed the project assembly from VizionLogs.LogRepositoryto ITVizion.VizionLogs.LogRepositoryand forgot to rename it in that Web.configfile. This was causing that ASP.NET Temp folder error telling me it could not find VizionLogs.LogRepository. It took me some time to figure out what was going on and where the error was... :)
我的问题:我从改名为项目装配VizionLogs.LogRepository到ITVizion.VizionLogs.LogRepository忘了它在重命名Web.config文件。这导致 ASP.NET Temp 文件夹错误告诉我它找不到VizionLogs.LogRepository. 我花了一些时间才弄清楚发生了什么以及错误在哪里...... :)
回答by Josh Mouch
If you use Visual Studio Performance Tools then it is possible that Visual Studio left a key in your web.config appsettings section. It causes a 32 bit library to load, which won't work if your application is loading in 64 bit mode.
如果您使用 Visual Studio 性能工具,那么 Visual Studio 可能会在您的 web.config appsettings 部分留下一个键。它会导致加载 32 位库,如果您的应用程序以 64 位模式加载,它将无法工作。
Check for the following and remove it:
检查以下内容并将其删除:
<add key="Microsoft.VisualStudio.Enterprise.AspNetHelper.VsInstrLocation" value="C:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Performance Tools\vsinstr.exe"/>
回答by Anwar
I had same problem. I just solve it by changing on web.config -> system.web -> compilation -> debug="false". Then it work fine
我有同样的问题。我只是通过更改 web.config -> system.web -> 编译 -> debug="false" 来解决它。然后它工作正常
回答by Shakoor Hussain Attari
removing temporary projects files in corresponding folder like for .net 4 from below folder will resolve the issue.
从下面的文件夹中删除相应文件夹中的临时项目文件(如 .net 4)将解决该问题。
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files"
“C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files”
also refer to this answer.
也可以参考这个答案。
回答by Zaif Ullah
Remove the following lines from web.config will resolve your error.
从 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=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>
回答by Ahmed Siddiqui
Please backup and remove the folder myfirst\159977c5\b9e740fc\App_global.asax.yfqtni9g.dll'
请备份并删除文件夹 myfirst\159977c5\b9e740fc\App_global.asax.yfqtni9g.dll'

