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.

Developer technologies | Visual Studio | Debugging
{count} votes

1 answer

Sort by: Most helpful
  1. Mahmoud Khaled 0 Reputation points
    2025-03-24T03:35:30.9466667+00:00

    To solve this problem, you should try one of these options:

    Install a new Windows and download all programs from scratch (not recommended).

    Install VirtualBox, then install Windows on it, and add your apps to the new Windows.

    I don’t know what I actually did to mess up my Windows, but this solution worked for me. If anyone has ideas about what’s going on with my Windows, please let me know in the comments.

    0 comments No comments

Your answer

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