MSBuild Build Error with ImageList in Windows Forms C#

Mahmoud Khaled 0 Reputation points
2025-03-10T05:16:22.89+00:00

Details

Encountering build errors when using the ImageList control in a Windows Forms application built with C#. The following errors are present after attempting to run the program:

Errors:

  1. Task host node exited prematurely. Diagnostic information may be found in files in the temporary files directory named MSBuild_*.failure.txt.
  2. The "GenerateResource" task's outputs could not be retrieved from the "FilesWritten" parameter. Object does not match target type.

Several attempts have been made to resolve the issue:

  1. Fixed .resx file corruption, as the ImageList component stores image resources in .resx files (e.g., Form1.resx).
  2. Ensured correct image formats, confirming that images in the ImageList are in formats like PNG, BMP, or JPEG.
  3. Cleaned and rebuilt the project using MSBuild commands:
   dotnet clean 
   dotnet restore 
   dotnet build
  1. Verified .NET SDK installation.
  2. Checked for architecture mismatch, ensuring the project’s target architecture (x86/x64) matches the SDK installation.
  3. Disabled MSBuild node reuse by adding the /nodeReuse:false option.

Despite these efforts, the same issue persists. Any guidance on resolving this problem would be appreciated.

Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
1,033 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.