This article has been archived. It is offered "as is" and will no longer be updated.
Source: Microsoft Support
RAPID PUBLISHING ARTICLES PROVIDE INFORMATION DIRECTLY FROM WITHIN THE MICROSOFT SUPPORT ORGANIZATION. THE INFORMATION CONTAINED HEREIN IS CREATED IN RESPONSE TO EMERGING OR UNIQUE TOPICS, OR IS INTENDED SUPPLEMENT OTHER KNOWLEDGE BASE INFORMATION.
Created a large managed solution using Visual Studio that contains many managed projects inside. The size of the solution can be greater than 300 MB depending on what's in each project in the solution. The size can variety due to the nature of the problem.
When building such a large solution from the IDE, the build may fail with OutOfMemoryException. The output window contains the following error message.
The "GenerateResource" task failed unexpectedly. System.OutOfMemoryException: Exception of type "System.OutOfMemoryException" was thrown.
The solution size is the root cause of the problem. This is a limitation memory usage in any process. What is happening here is that the IDE is loading all files into memory and running out of process memory to continue due to the size of the solution. A process can ideally allocate 4 GB memory in 43 bit, but that is divided into 2 GB for user and 2 for kernel. When the process gets close to 2 GB memory usage it will throw OutOfMemory exception.
Reducing the solution size by removing one project or a few projects will resolve the issue. Having many projects in a single solution is not good practice as well.
MICROSOFT AND/OR ITS SUPPLIERS MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY, RELIABILITY OR ACCURACY OF THE INFORMATION CONTAINED IN THE DOCUMENTS AND RELATED GRAPHICS PUBLISHED ON THIS WEBSITE (THE “MATERIALS”) FOR ANY PURPOSE. THE MATERIALS MAY INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS AND MAY BE REVISED AT ANY TIME WITHOUT NOTICE.
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, MICROSOFT AND/OR ITS SUPPLIERS DISCLAIM AND EXCLUDE ALL REPRESENTATIONS, WARRANTIES, AND CONDITIONS WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO REPRESENTATIONS, WARRANTIES, OR CONDITIONS OF TITLE, NON INFRINGEMENT, SATISFACTORY CONDITION OR QUALITY, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE MATERIALS.