在构建包含 19 个项目的 VS 2008 解决方案时,我有时会得到:

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& taskResult)   C:\Windows\Microsoft.NET\Framework\v3.5

通常发生在 VS 已经运行了大约 4 个小时之后;使 VS 正确编译的唯一方法是关闭 VS,然后重新启动它。

我在一台带有 3GB 内存的机器上。 TaskManager 显示 devenv.exe 工作集为 578060K,整个机器的内存分配为 1.78GB。它应该有足够多的内存来生成资源。

最佳答案

我曾经用更大的解决方案一次又一次地解决这个问题。我的策略是将较大的解决方案分解为较小的解决方案。

你也可以试试:

http://stevenharman.net/blog/archive/2008/04/29/hacking-visual-studio-to-use-more-than-2gigabytes-of-memory.aspx

关于visual-studio - Visual Studio 错误 : The "GenerateResource" task failed unexpectedly,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15034/

10-11 22:11
查看更多