我正在尝试运行一个有10年历史的C# Visual Studio项目
由于某些原因,我不能删除或编辑表单中的任何图像
如果在使用视图设计器时尝试编辑PictureBox的图像属性,则会收到“属性值无效”错误。详细信息框显示为"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
发布于 2017-06-29 14:20:41
在将目标框架更改为.Net 2.0后,我开始收到更有意义的错误消息:各种形式的.resx文件都已损坏,因此删除它们就解决了问题
https://stackoverflow.com/questions/44808943
复制