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

时间:2017-06-28 17:20:43

标签: c# visual-studio visual-studio-2010 gdi+ picturebox

我试图运行一个已有10年历史的C#Visual Studio项目

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

如果我在使用视图设计器时尝试编辑PictureBox的图像属性,我会得到一个"属性值无效"错误。详细信息框显示" 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

1 个答案:

答案 0 :(得分:0)

将目标框架更改为.Net 2.0后,我开始收到更有意义的错误消息 事实证明各种形式的.resx文件已损坏,因此删除它们解决了问题