属性 值无效 - GDI+ 中发生一般性错误

Property value is not valid - A generic error occurred in GDI+

我正在尝试 运行 一个 10 年前的 C# Visual Studio 项目

出于某种原因,我无法删除或编辑表单中的任何图像

如果我在使用视图设计器时尝试编辑 PictureBox 的图像 属性,我会收到 "Property value is not valid" 错误。详细信息框显示为 "A generic error occurred in GDI+."

即使更改 PictureBox 的大小也会触发相同的错误

虽然不是那么相关,但这是表单的代码。在我看来,这只是视图设计器自动生成的代码:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Threading;

namespace AppCliente.Vista
{
    public class frmLogin : System.Windows.Forms.Form
    {
        private System.Windows.Forms.PictureBox picLogin;
        private System.ComponentModel.Container components = null;

        private frmLogin()
        {           
            InitializeComponent();      
        }

        private void InitializeComponent()
        {
            this.picLogin = new System.Windows.Forms.PictureBox();
            ((System.ComponentModel.ISupportInitialize)(this.picLogin)).BeginInit();
            this.SuspendLayout();
            // picLogin
            // 
            this.picLogin.Location = new System.Drawing.Point(-1, -3);
            this.picLogin.Name = "picLogin";
            this.picLogin.Size = new System.Drawing.Size(264, 48);
            this.picLogin.TabIndex = 5;
            this.picLogin.TabStop = false;
            this.picLogin.Click += new System.EventHandler(this.picLogin_Click);       
            this.Controls.Add(this.picLogin); 
            ((System.ComponentModel.ISupportInitialize)(this.picLogin)).EndInit();

        }


        private void picLogin_Click(object sender, EventArgs e)
        {

        }
    }
}

可能是什么原因造成的?

如果有用,我在尝试编译项目时会收到​​以下错误:

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__26.MoveNext() AppCliente

将目标框架更改为 .Net 2.0 后,我开始收到更多有意义的错误消息 原来各种形式的.resx文件都损坏了,所以删除它们解决了问题