visual-studio 未知的构建错误,抛出了“System.OutOfMemoryException”类型的异常

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1068437/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 10:42:54  来源:igfitidea点击:

Unknown build error, 'Exception of type 'System.OutOfMemoryException' was thrown

visual-studiovisual-studio-2008exceptioncompiler-constructionbuild-process

提问by m1k4

We have VS.Net solution with 20 projects in it.

我们有 VS.Net 解决方案,其中包含 20 个项目。

Occasionaly, in VS.NET, when we try to build/debug our solution, we get following error:

有时,在 VS.NET 中,当我们尝试构建/调试我们的解决方案时,我们会收到以下错误:

Unknown build error, 'Exception of type 'System.OutOfMemoryException' was thrown

未知的构建错误,抛出了“System.OutOfMemoryException”类型的异常

Only way to "fix" this issue is to reopen Visual Studio and then solution build goes well, but again after some time OutOfMemory exception occur again. It's really annoying to reopen Visual Studio couple times a day, so do you know some workaround for this issue ?

“修复”此问题的唯一方法是重新打开 Visual Studio,然后解决方案构建顺利,但一段时间后再次出现 OutOfMemory 异常。一天重新打开几次 Visual Studio 真的很烦人,所以你知道这个问题的一些解决方法吗?

采纳答案by m1k4

JetBrains is aware of this issue, and they provide some fix for it, using this fix solved my problems for now:

JetBrains 意识到了这个问题,他们提供了一些修复,使用这个修复解决了我现在的问题:

http://www.jetbrains.net/confluence/display/ReSharper/OutOfMemoryException+Fix

http://www.jetbrains.net/confluence/display/ReSharper/OutOfMemoryException+Fix



Edit: However, OutOfMemory exception is occuring again, but it's not as often as it is when I dont use this JetBrains fix.

编辑:但是,OutOfMemory 异常再次发生,但不像我不使用此 JetBrains 修复程序时那样频繁。

回答by Razvan Popa

Or you can just minimize Visual Studio for about 10 seconds (see in task manager how the memory usage of devenv.exe drops when minimized). This works for me in most cases.I rarely have to close VS to get rid of this error.

或者,您可以将 Visual Studio 最小化约 10 秒(在任务管理器中查看最小化时 devenv.exe 的内存使用情况如何下降)。这在大多数情况下对我有用。我很少需要关闭 VS 来摆脱这个错误。

回答by Prashanth

According to what Microsoft recommends, it is not a good idea to have lots of projects within a single solution.

根据 Microsoft 的建议,在一个解决方案中包含多个项目并不是一个好主意。

Check out this link http://support.microsoft.com/kb/949755.

查看此链接http://support.microsoft.com/kb/949755

But the solution suggested in the article is not something that be straight away used, because of the code refactoring costs involved.

但是文章中提出的解决方案并不是直接使用的,因为涉及到代码重构成本。

Have you tried building the solution from outside the IDE. (Something like MSBUILD). That might help.

您是否尝试过从 IDE 外部构建解决方案。(类似于 MSBUILD)。那可能会有所帮助。

回答by Sven

I have the same Issue if I use ReSharper and run several UnitTests (with enabled CodeCoverage).

如果我使用 ReSharper 并运行多个 UnitTest(启用 CodeCoverage),我会遇到同样的问题。

I also assume this is a ReSharper problem. And since I disble it while I'm running Unittest the Exception never appears again.

我还假设这是一个 ReSharper 问题。由于我在运行 Unittest 时禁用了它,因此 Exception 再也不会出现。

BTW - Disabling it when the exception throws (as mentioned in the comments above) doesn't help, because of disabling it while VS is running will not unload it from memory. The only way to force the unload is to tear down all AppDomains which have loaded the DLL. In a VS Package scenario this means you have to tear down the entire VS process :(

顺便说一句 - 在异常抛出时禁用它(如上面的评论中所述)没有帮助,因为在 VS 运行时禁用它不会从内存中卸载它。强制卸载的唯一方法是拆除所有已加载 DLL 的 AppDomain。在 VS Package 场景中,这意味着您必须拆除整个 VS 过程:(

回答by Viishnuu

VS reinstallation is temporary solution. Jus increase your machine Virtual memory size. this resolves this issue.

VS 重新安装是临时解决方案。只需增加您的机器虚拟内存大小。这解决了这个问题。

ref below link - http://windows.microsoft.com/en-in/windows/change-virtual-memory-size#1TC=windows-7

参考以下链接 - http://windows.microsoft.com/en-in/windows/change-virtual-memory-size#1TC=windows-7