【问题标题】:System.OutOfMemoryException error on js file loadjs文件加载时出现System.OutOfMemoryException错误
【发布时间】:2020-06-21 08:17:17
【问题描述】:

@Scripts.Render() 抛出此错误;

An exception of type 'System.OutOfMemoryException' occurred in WebGrease.dll but was not handled in user code

当我试图包含一个 10 MB 的 js 文件时,在我的布局页面中。其他脚本工作正常。

【问题讨论】:

  • 天哪,JS文件那么大,你到底为什么需要那个?!
  • 其他js文件的大小是多少?
  • 其他文件小于 1 MB。我尝试添加这个 js,因为我的客户不喜欢源代码中的那个大的 DevExpress DXR 扩展。所以我想我可以把它保存为一个文件并通过包渲染它。

标签: asp.net-mvc webgrease


【解决方案1】:

首先,这并不可取。上传这么大的文件并不是一个很好的解决方案。请考虑其他方法。

无论如何,您可以尝试以下几件事来解决您的问题;

解决方案 1。如果您在 64 位 Windows 上运行并且有足够的可用内存,请确保在 project properties > build properties 中正确设置了平台目标。

解决方案 2。如果您使用的是 .NET 4.5 或更高版本,您可以将此行添加到 App.Config 的运行时部分:

<runtime> 
   <gcallowverylargeobjects enabled="true"></gcallowverylargeobjects> 
</runtime>

解决方案 3。你可以在你的网络配置文件中增加maxRequestLength。

<httpRuntime executionTimeout="3600" maxRequestLength="102400"/>

让我知道这是否有效。

参考:

[1]https://support.microsoft.com/en-us/help/2020006/how-to-troubleshoot-out-of-memory-issues-system-outofmemoryexception-i [2]https://forums.asp.net/t/1548237.aspx?ASP+NET+2+0+System+out+of+memory+exception [3]How to upload up 10gb file on ASP.NET [4]https://systemoutofmemory.com/blogs/the-programmer-blog/c-out-of-memory-exception

【讨论】:

  • 感谢您的帮助,但没有成功。虽然我仍然可以通过
猜你喜欢
  • 2015-05-17
  • 2018-11-15
  • 1970-01-01
  • 2022-11-14
  • 1970-01-01
  • 1970-01-01
  • 2021-12-31
  • 1970-01-01
  • 2011-03-21
相关资源
最近更新 更多