我正在使用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 vs2010ASP.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
我检查并完全访问了“Temporary ASP.NET Files”及其用户组的子文件夹和文件。
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.
我无法追踪任何错误。请帮帮我......
答案 0 :(得分:23)
在我尝试开始性能测试后,我遇到了类似的问题。
我删除了system.web
>中的assemblyPostProcessorType属性compilation
中的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>
答案 1 :(得分:9)
如果使用Visual Studio Performance Tools,则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"/>
答案 2 :(得分:3)
其中一个解决方案是从临时asp.net文件夹中删除那些始终适合我的文件。
答案 3 :(得分:2)
我认为你有类似的问题: Could not load file or assembly 'file:///C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\ asp.net vs2010
接受的回答是:
尝试执行完整的解决方案构建。如果这不起作用,请单击 构建 - &gt;清洁解决方案如果错误仍然存在,请删除所有内容 C:\ WINDOWS \ Microsoft.NET \ Framework \ v4.0.30319 \ Temporary ASP.NET Files \ parktms文件夹并重复。
答案 4 :(得分: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.LogRepository
重命名为ITVizion.VizionLogs.LogRepository
,忘了在Web.config
文件中重命名。这导致ASP.NET Temp文件夹错误告诉我它找不到VizionLogs.LogRepository
。我花了一些时间来弄清楚发生了什么以及错误在哪里......:)
答案 5 :(得分:1)
转到注册表并输入
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion]
"EnableLog"=dword:00000001
"LogFailures"=dword:00000001
"LogPath"="c:\\temp\\fusionLog"
对于加载的程序集,您将在c:\ temp \ fusionLog
中找到一个日志在那里你会发现缺少什么依赖。
答案 6 :(得分:1)
从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>
答案 7 :(得分:0)
我有同样的问题。我只是通过改变来解决它 在web.config上 - &gt; system.web - &gt;编译 - &gt;调试=&#34;假&#34 ;. 然后它工作正常
答案 8 :(得分:0)
从下面的文件夹中删除相应项目(如.net 4)中的临时项目文件将解决此问题。
“ C:\ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ ASP.NET临时文件”
也请参阅此答案。
答案 9 :(得分:0)
删除(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应用程序时,已编译的代码位于“临时ASP.NET文件”文件夹中。此文件夹是.NET Framework安装位置的子目录
除此之外,另一篇文章建议仔细检查已安装的targetFramework和框架
答案 10 :(得分:0)
对于我来说,我在web.config中找到bin文件夹,如下所示:
<appSettings>
<add key="webSettingFolder" value="C:\Users\ali eshghi\source\repos\SalesWebApiDotNetFramWork\SalesWebApiDotNetFramWork\bin\"/>
</appSettings>
此错误消失之后。