我们有一个应用程序需要在Windows 7环境中开始测试和开发。它在VS2008的WinXP下编译的很好,没有问题。然而,当我今天使用VS2008在Windows7机器上编译它时,我得到了以下错误:
Error 12 The "GenerateResource" task failed unexpectedly.
System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(MemoryStream stream)
at System.Drawing.Image.System.Runtime.Serialization.ISerializable.GetObjectData(SerializationInfo si, StreamingContext context)
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph)
at System.Resources.ResourceWriter.WriteValue(ResourceTypeCode typeCode, Object value, BinaryWriter writer, IFormatter objFormatter)
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, List`1 inputs, List`1 outputs, Boolean sourcePath, String language, String namespacename, String resourcesNamespace, String filename, String classname, Boolean publicClass)
at Microsoft.Build.Tasks.ProcessResourceFiles.Run(TaskLoggingHelper log, ITaskItem[] assemblyFilesList, List`1 inputs, List`1 outputs, Boolean sourcePath, String language, String namespacename, String resourcesNamespace, String filename, String classname, Boolean publicClass)
at Microsoft.Build.Tasks.GenerateResource.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)我无论如何也不能把这本书写下来。我访问了msdn论坛,发现这是许多人的问题,但MS或其他任何人都没有提供一致的解决方案。
以前有没有人看到过这个问题并解决了它?请建议是否需要!
谢谢
发布于 2012-10-18 22:30:23
经过几个小时的故障排除,我使用MSBUILD "my solution file path here“在VS2010命令行提示符下打开并构建了项目。这提供了一个更直观的构建事件序列,我发现我的项目在编译Form16之后就失败了。表单编译似乎是按照解决方案资源管理器中对象的顺序进行的。所以我检查了下一个表单,发现它包含一个图片框。我还检查了该窗体之后的窗体,发现无法打开设计器而不出错(对象引用未设置为对象的实例)。因此,很明显,现在的问题是双重的。
为了解决这个问题,我不得不从第一个表单中删除图片框对象,因为它似乎已经损坏,我发现它有问题(它没有以任何方式使用)。我发现具有空引用异常的第二个表单使用的是用户控件。用户控件的构造函数的代码试图在调用InitializeComponent()之前将对象传递给容器。这创建了空引用,因为在调用有问题的代码时,InitializeComponent中还没有创建容器事件。
在解决了上面段落中的问题后,我的解决方案在Windows7下编译。
发布于 2012-08-13 06:36:27
我使用命令行msbuild进行了编译,发现了问题所在。
这是一个类中的resx文件,其中有一个未使用的图像。我把它去掉了,一切都好起来了。现在可以很好地构建了。
发布于 2011-08-11 05:02:57
如果我没记错的话,我想是针对Windows7的GDI更新。也许这样就能解决问题了。您的解决方案是在commsnd行上使用Msbuild构建的吗?
https://stackoverflow.com/questions/7017731
复制相似问题