title: Visual Studio Error: The "GenerateResource" task failed unexpectedly
body: <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>