Visual Studio 2022 - VB.Net Desktop application error message hindering functionality

Simon 286 Reputation points
2024-05-16T21:25:31.1233333+00:00

My desktop application developed with Visual Studio 2022 - VB.Net codes, generated an error message that is hindering the functionality of the application.

Please see the message below:

Severity Code Description Project File Line Suppression State

Error 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.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 Microsoft.Build.Tasks.ProcessResourceFiles.WriteResources(ReaderInfo reader, IResourceWriter writer)

at Microsoft.Build.Tasks.ProcessResourceFiles.WriteBinaryResources(ReaderInfo reader, String filename)

at Microsoft.Build.Tasks.ProcessResourceFiles.ProcessFile(String inFile, String outFileOrDir)

at Microsoft.Build.Tasks.ProcessResourceFiles.Run(TaskLoggingHelper log, ITaskItem[] assemblyFilesList, List1 inputs, List1 satelliteInputs, List`1 outputs, Boolean sourcePath, Boolean usePreserializedResources, String language, String namespacename, String resourcesNamespace, String filename, String classname, Boolean publicClass, Boolean extractingResWFiles, String resWOutputDirectory, Boolean logWarningForBinaryFormatter)

at Microsoft.Build.Tasks.GenerateResource.Execute()

at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()

at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() Payroll C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets 3386

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,737 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jiachen Li-MSFT 32,376 Reputation points Microsoft Vendor
    2024-05-17T05:31:37.5133333+00:00

    Hi @Simon ,

    Please check the following things.

    1. Ensure that all image files used in your project are accessible, and that the application has the necessary permissions to read and write these files. If the paths are incorrect or the files are missing, GDI+ will throw an error.
    2. Make sure that the image files are not corrupted. You can open the image files manually to verify they are intact. Sometimes a corrupted image file can cause GDI+ to fail.
    3. Ensure that the size of your images and resource files are within acceptable limits.
    4. Ensure that there is sufficient disk space on the drive where the application is running. Lack of disk space can cause unexpected errors in file operations.

    Best Regards.

    Jiachen Li


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

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.