none
GDI+ compilation error in VS2010 in WIN7 RRS feed

  • Question

  • Hello,

    After migrating my vb.net project from WIN XP to WIN7 I have a compliation error when building the project:

    Error 2 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(ReaderInfo reader, IResourceWriter writer)
       at Microsoft.Build.Tasks.ProcessResourceFiles.WriteResources(ReaderInfo reader, String filename)
       at Microsoft.Build.Tasks.ProcessResourceFiles.ProcessFile(String inFile, String outFileOrDir)
       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, Boolean extractingResWFiles, String resWOutputDirectory)
       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, Boolean extractingResWFiles, String resWOutputDirectory)
       at Microsoft.Build.Tasks.GenerateResource.Execute()
       at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
       at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext() BioVision

    I am running the VS2010 as administrator, with full permissions.

    I have Searched the web several times, but can't find anything that will fix this, I even haven't understood why exactly is this happening?

    Help will be highly appreciated...

    Thursday, April 11, 2013 7:08 AM

Answers

  • I would go through your resources of all your forms and see if there are any images there you can get rid of. Sounds like one of the images is giving you grief

    This link gives a description of what others have done. I've copied the relevant part below: http://stackoverflow.com/questions/7017731/c-sharp-compile-issue-in-windows-7-a-generic-error-occurred-in-gdi

    After hours of troubleshooting, I opened and built the project using the VS 2010 command line prompt using MSBUILD "my solution file path here". This provided a more visible sequence of build events, and I found my project was failing just after it compiled form 16. The forms compiling appeared to be going in order of the objects in the solution explorer. So I checked the next form and found it contained a picture box. I also checked the form after that one and found I could not open the designer without errors(object reference not set to instance of object). So apparently, the problem was now two-fold.

    To resolve I had to remove the picture box object from the first form I identified as problematic (it was not being used any way) as it appeared to be corrupted. I found the second form with the null reference exception was using a user control. The code for the constructor of the user control was attempting to pass an object to a container before calling InitializeComponent(). This created the null reference since the container hadn't event been created in InitializeComponent when the problematic code was called.

    After resolving the issues in the above paragraph my solution compiled under Windows 7.

    • Marked as answer by Assaf Harel Thursday, April 11, 2013 9:06 AM
    Thursday, April 11, 2013 8:09 AM

All replies

  • I would go through your resources of all your forms and see if there are any images there you can get rid of. Sounds like one of the images is giving you grief

    This link gives a description of what others have done. I've copied the relevant part below: http://stackoverflow.com/questions/7017731/c-sharp-compile-issue-in-windows-7-a-generic-error-occurred-in-gdi

    After hours of troubleshooting, I opened and built the project using the VS 2010 command line prompt using MSBUILD "my solution file path here". This provided a more visible sequence of build events, and I found my project was failing just after it compiled form 16. The forms compiling appeared to be going in order of the objects in the solution explorer. So I checked the next form and found it contained a picture box. I also checked the form after that one and found I could not open the designer without errors(object reference not set to instance of object). So apparently, the problem was now two-fold.

    To resolve I had to remove the picture box object from the first form I identified as problematic (it was not being used any way) as it appeared to be corrupted. I found the second form with the null reference exception was using a user control. The code for the constructor of the user control was attempting to pass an object to a container before calling InitializeComponent(). This created the null reference since the container hadn't event been created in InitializeComponent when the problematic code was called.

    After resolving the issues in the above paragraph my solution compiled under Windows 7.

    • Marked as answer by Assaf Harel Thursday, April 11, 2013 9:06 AM
    Thursday, April 11, 2013 8:09 AM
  • Hi FarnhamSurrey,

    Thanks for the prompt reply!

    Removing the images didn't help, but then I stumbled upon a form that opened with designer error connected to the grid color on the form - after changing the grid color to something else the program now runs, BUT when I do Rebuild on all the solution it still shows the GDI+ error (though running the program and debugging it works...), really weird :\

    Thursday, April 11, 2013 9:11 AM