1

We have an application that we need to begin testing and developing in Windows 7 environment. It works fine compiling under WinXP in VS2008, no problems. However when I went to compile it on a windows 7 machine using VS2008 today I get the following error:

    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)

I cannot for the life of me run this one down. I have visited the msdn forums and find that it is an issue for a lot of people, but no consistent solution has been provided by MS or anyone else.

Has anyone seen this before and fixed it? Please advise is needed!

Thanks

Olivier Jacot-Descombes
  • 104,806
  • 13
  • 138
  • 188
Encryption
  • 1,809
  • 9
  • 37
  • 52
  • A little more context might be helpful. What does this application do? Is it performing special interop via p/invoke etc? – Mateo Aug 10 '11 at 21:04
  • It is medical software. I believe this may have something to do with the handling of Images. We save patient photos or logos using Image.Save but I have commented out all Image.Save code and still get the error. – Encryption Aug 10 '11 at 21:14
  • Seems like there is an error when saving your resources. I've seen this error when not having the rights to save a file to a certain location. What happens if you run VS as an admin? – Oskar Kjellin Aug 10 '11 at 21:22
  • I am an admin on the PC. That should not be an issue... – Encryption Aug 10 '11 at 21:26
  • Are you running visual studio as an admin? YOu have to right click and run as admin. I've seen this issue even when being an admin when not having access to the directory... – Oskar Kjellin Aug 10 '11 at 21:28
  • Yeh, I ran it as an admin because I was curious...and I compiled to still get the same error. This is really annoying and M$ doesn't have answers either – Encryption Aug 10 '11 at 21:30

6 Answers6

3

I compiled using the command line msbuild and that identified the problem location.

It was a resx file in a class which had one unused image in it. I removed that and all was good again. Can build fine now.

Garry
  • 31
  • 2
2

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.

Encryption
  • 1,809
  • 9
  • 37
  • 52
0

Delete the resources from the resource manager (right click on each and delete) then add them back. for me it solve the problem.

0

i had same problem. i just used msbuild myProject.sln command and it fixed and built successfully with no errors! now i can manually build my solution. no need to reAdding my resources

Nima M
  • 1
  • 1
0

There is a GDI update for Windows 7, I think, if I'm not mistaken. Maybe that will solve the issue. Does your solution build using Msbuild on the commsnd line?

Erik A. Brandstadmoen
  • 10,430
  • 2
  • 37
  • 55
0

Do you use TIFF images in your app?

Some time ago, I also had a problem with TIFF images as part of reports that wouldn't compile under Win7 x64 although it compiled like a charm under Vista x86. The error message also involved GDI+. I saved the images under a different format (PNG) and the problem vanished.

At the time (around March 2011), I first ensured that my Windows was up-to-date but it didn't solve the problem. So maybe there is such an update as mentionned by Erik but it didn't come through Windows Update back then (Maybe it's newer).

Serge Wautier
  • 21,494
  • 13
  • 69
  • 110
  • No TIFF images in the project. I have png and ico images. I've already gone the way of removing all image files and tryin to compile and still no luck. – Encryption Aug 10 '11 at 21:32