asp.net 引发了“System.OutOfMemoryException”类型的异常,

zfycwa2u  于 2022-11-26  发布在  .NET
关注(0)|答案(5)|浏览(260)

我遇到以下问题

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

我没有更改代码?这个问题是什么意思,因为我看到没有更多关于错误的声明

hvvq6cgz

hvvq6cgz1#

这个问题通常发生在一些过程中,如加载大量数据到内存流,而您的系统内存无法存储这么多的数据。尝试通过以下命令清除临时文件夹
开始-〉运行-〉%temp%

fnvucqvd

fnvucqvd2#

另一个要尝试的是
工具-〉选项-〉搜索 IIS -〉勾选 * 为网站和项目使用64位版本的IIS Express *。

cdmah0mi

cdmah0mi3#

在调试模式下运行

当您开发和两柴应用程序时,通常会将web.config档中的debug属性设定为true,并在两柴模式中编译DLL。不过,在将应用程序部署到测试或实际执行之前,您应该在出版模式中编译元件,并将debug属性设定为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

zz2j4svz

zz2j4svz4#

我只是重新启动了Visual Studio并执行了IISRESET,这解决了问题。

ia2d9nvy

ia2d9nvy5#

如果您使用的是IIS Express,请从任务栏通知区域的IIS Express中选择Show All Application,然后选择Stop All
现在重新运行应用程序。

相关问题