29

我遇到了以下问题

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +567
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +192
   System.Reflection.Assembly.Load(String assemblyString) +35
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +123

[ConfigurationErrorsException: Exception of type 'System.OutOfMemoryException' was thrown.]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +11569328
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +485
   System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +79
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +337
   System.Web.Compilation.BuildManager.CallPreStartInitMethods() +280
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1167

[HttpException (0x80004005): Exception of type 'System.OutOfMemoryException' was thrown.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11702064
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4870277

我没改代码?这个问题是什么意思,正如我所见,没有更多关于错误的声明

4

5 回答 5

35

当某些过程(例如将大量数据加载到内存流)并且您的系统内存无法存储这么多数据时,通常会出现此问题。尝试通过给出命令清除临时文件夹

开始 -> 运行 -> %temp%

于 2013-08-26T07:01:21.437 回答
16

另一件要尝试的是

工具 -> 选项 -> 搜索IIS -> 勾选Use the 64 bit version of IIS Express for web sites and projects

为网站和项目使用 64 位版本的 IIS Express 截图

于 2017-02-22T01:15:33.727 回答
14

在调试模式下运行

在开发和调试应用程序时,通常会在 web.config 文件中的 debug 属性设置为 true 并在调试模式下编译 DLL 的情况下运行。但是,在将应用程序部署到测试或生产之前,您应该在发布模式下编译组件并将调试属性设置为 false。

在调试模式下运行时,ASP.NET 在许多级别上的工作方式不同。事实上,当您在调试模式下运行时,GC 将允许您的对象存活更长时间(直到作用域结束),因此在调试模式下运行时您总是会看到更高的内存使用率。

在调试模式下运行的另一个经常未意识到的副作用是,通过 webresource.axd 和 scriptresource.axd 处理程序提供的客户端脚本将不会被缓存。这意味着每个客户端请求都必须下载任何脚本(例如 ASP.NET AJAX 脚本),而不是利用客户端缓存。这可能会导致严重的性能损失。

来源:http: //blogs.iis.net/webtopics/archive/2009/05/22/troubleshooting-system-outofmemoryexceptions-in-asp-net.aspx

于 2014-12-22T21:33:06.553 回答
7

我刚刚重新启动了 Visual Studio 并执行了 IISRESET 解决了这个问题。

于 2016-09-29T14:30:04.433 回答
6

如果您使用的是 IIS Express,请Show All Application从任务栏通知区域的 IIS Express 中选择,然后选择Stop All.

现在重新运行您的应用程序。

于 2016-02-10T11:18:35.903 回答