<p>When building a VS 2008 solution with 19 projects I sometimes get:</p>

<pre><code>The "GenerateResource" task failed unexpectedly.
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at System.IO.MemoryStream.set_Capacity(Int32 value)
   at System.IO.MemoryStream.EnsureCapacity(Int32 value)
   at System.IO.MemoryStream.WriteByte(Byte value)
   at System.IO.BinaryWriter.Write(Byte value)
   at System.Resources.ResourceWriter.Write7BitEncodedInt(BinaryWriter store, Int32 value)
   at System.Resources.ResourceWriter.Generate()
   at System.Resources.ResourceWriter.Dispose(Boolean disposing)
   at System.Resources.ResourceWriter.Close()
   at Microsoft.Build.Tasks.ProcessResourceFiles.WriteResources(IResourceWriter writer)
   at Microsoft.Build.Tasks.ProcessResourceFiles.WriteResources(String filename)
   at Microsoft.Build.Tasks.ProcessResourceFiles.ProcessFile(String inFile, String outFile)
   at Microsoft.Build.Tasks.ProcessResourceFiles.Run(TaskLoggingHelper log, ITaskItem[] assemblyFilesList, ArrayList inputs, ArrayList outputs, Boolean sourcePath, String language, String namespacename, String resourcesNamespace, String filename, String classname, Boolean publicClass)
   at Microsoft.Build.Tasks.GenerateResource.Execute()
   at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean&amp; taskResult)   C:\Windows\Microsoft.NET\Framework\v3.5
</code></pre>

<p>Usually happens after VS has been running for about 4 hours; the only way to get VS to compile properly is to close out VS, and start it again.</p>

<p>I'm on a machine with 3GB Ram. TaskManager shows the devenv.exe working set to be 578060K, and the entire memory allocation for the machine is 1.78GB. It should have more than enough ram to generate the resources.</p>

[{'answer_id': 15055, 'author': 'Kev', 'author_id': 419, 'author_profile': 'https://Stackoverflow.com/users/419', 'pm_score': 1, 'selected': True, 'text': '<p>I used to hit this now and again with larger solutions. My tactic was to break the larger solution down into smaller solutions.</p>\n\n<p>You could also try:</p>\n\n<p><a href="http://stevenharman.net/blog/archive/2008/04/29/hacking-visual-studio-to-use-more-than-2gigabytes-of-memory.aspx" rel="nofollow noreferrer">http://stevenharman.net/blog/archive/2008/04/29/hacking-visual-studio-to-use-more-than-2gigabytes-of-memory.aspx</a></p>\n'}, {'answer_id': 15063, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': '<p>Sounds like a bug.</p>\n\n<p><a href="http://www.codeprof.com/dev-archive/66/6-27-664019.shtm" rel="nofollow noreferrer">http://www.codeprof.com/dev-archive/66/6-27-664019.shtm</a></p>\n\n<p>Toward the bottom, someone suggests adding:</p>\n\n<blockquote>\n  <p>&lt;GenerateResourceNeverLockTypeAssemblies>true&lt;/GenerateResourceNeverLockTypeAssemblies></p>\n</blockquote>\n\n<p>to your project file. Seems kind of dubious, but worth a shot.</p>\n'}, {'answer_id': 15067, 'author': 'Stu', 'author_id': 414, 'author_profile': 'https://Stackoverflow.com/users/414', 'pm_score': 3, 'selected': False, 'text': '<p>From <a href="https://social.msdn.microsoft.com/Forums/vstudio/en-US/5154ef26-ccfe-44d5-a322-6804b61ac774/systemoutofmemoryexception?forum=clr" rel="nofollow noreferrer">https://social.msdn.microsoft.com/Forums/vstudio/en-US/5154ef26-ccfe-44d5-a322-6804b61ac774/systemoutofmemoryexception?forum=clr</a>:</p>\n\n<p>Try deleting the .suo file and re-opening the solution.</p>\n'}, {'answer_id': 4811373, 'author': 'Chris Woodruff', 'author_id': 495565, 'author_profile': 'https://Stackoverflow.com/users/495565', 'pm_score': 1, 'selected': False, 'text': '<p>In case someone else is looking in the future...</p>\n\n<p>In my case, turned out I had a corrupted resx file.<br>\nI had increased my GDI handles and the compile error went away.</p>\n\n<p>But then when I tried to run the app (with the debugger),\nWe have a login screen that loads the main screen.  The login screen called the main screen\'s "show" event... and the main object never got instantiated - with no error\'s being raised. </p>\n\n<p>I reverted the resx file to a previous one and everything is fine now.</p>\n\n<p>Visual Studio 2008, VB.Net, Windows 7</p>\n'}, {'answer_id': 8679710, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': '<p>Can you please try adding this property under the first PropertyGroup in your project file?</p>\n\n<pre><code>&lt;GenerateResourceNeverLockTypeAssemblies&gt;true&lt;/GenerateResourceNeverLockTypeAssemblies&gt;\n</code></pre>\n\n<p>Let me know if that works.</p>\n'}, {'answer_id': 34311467, 'author': 'user5686483', 'author_id': 5686483, 'author_profile': 'https://Stackoverflow.com/users/5686483', 'pm_score': 0, 'selected': False, 'text': '<p>I have already passed by this erros sometimes. All you must do is delete all files in the obj path. After that clean and rebuild your solution and it´s done.</p>\n'}, {'answer_id': 34332233, 'author': 'Sten Björsell', 'author_id': 5687641, 'author_profile': 'https://Stackoverflow.com/users/5687641', 'pm_score': 0, 'selected': False, 'text': '<p>"Clean solution" works fine. Top Menu Build ->Clean , then build, debug and \npublish all work fine again.  Also antivirus like AVAST best disabled to publish and install trouble free. Re-enable after.</p>\n'}, {'answer_id': 53006965, 'author': 'gowtham kondari', 'author_id': 10009737, 'author_profile': 'https://Stackoverflow.com/users/10009737', 'pm_score': 0, 'selected': False, 'text': '<p>TFS likes to mark files as Read Only.\ndelete the contents of obj/x86 </p>\n'}]
['https://Stackoverflow.com/questions/15034', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1365/']