RESX文件产生"" GenerateResource"任务意外失败"例外

时间:2014-03-18 21:14:56

标签: vb.net exception

我收到错误

Error   142 The "GenerateResource" task failed unexpectedly.
System.Runtime.InteropServices.ExternalException (0x80004005): Common error in GDI+.
   bei System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
   bei System.Drawing.Image.Save(MemoryStream stream)
   bei System.Drawing.Image.System.Runtime.Serialization.ISerializable.GetObjectData(SerializationInfo si, StreamingContext context)
   bei System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
   bei System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
   bei System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
   bei System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
   bei System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph)
   bei System.Resources.ResourceWriter.WriteValue(ResourceTypeCode typeCode, Object value, BinaryWriter writer, IFormatter objFormatter)
   bei System.Resources.ResourceWriter.Generate()
   bei System.Resources.ResourceWriter.Dispose(Boolean disposing)
   bei System.Resources.ResourceWriter.Close()
   bei Microsoft.Build.Tasks.ProcessResourceFiles.WriteResources(ReaderInfo reader, IResourceWriter writer)
   bei Microsoft.Build.Tasks.ProcessResourceFiles.WriteResources(ReaderInfo reader, String filename)
   bei Microsoft.Build.Tasks.ProcessResourceFiles.ProcessFile(String inFile, String outFileOrDir)
   bei 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, Boolean extractingResWFiles, String resWOutputDirectory)
   bei 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, Boolean extractingResWFiles, String resWOutputDirectory)
   bei Microsoft.Build.Tasks.GenerateResource.Execute()
   bei Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   bei Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()    prjMyProject

我现在花了两天时间处理此错误,从我的项目中删除表单和类,甚至是所有互操作类型。什么都没有帮助。

有人知道如何跟踪此错误吗?

我尝试过ProcMon,但我没有看到任何可以帮助我的东西(好吧,我不知道该寻找什么,这就是让它变得更难的原因。)

2 个答案:

答案 0 :(得分:2)

您的表单上是否有可能已损坏的嵌入图像?

您可以在设计器中打开所有表单和用户控件而不会出错吗?

请参阅:Compiler Issue in Windows 7: A generic error occurred in GDI+

答案 1 :(得分:0)

我修复它的方式,是通过所有嵌入图像的窗口,一个接一个。然后我找到了“罪犯”,设计师在打开它时坠毁了。

我只需删除designer.cs上对此图像的引用,瞧!