是 NET.Framework 4.8。重写为 NET.Core 5。那里没有什么可重写的。2班的东西。
当我尝试显示我更改了空格的表单时,会发生不允许显示表单的错误
索引超出范围。索引必须是一个正数,并且它的大小不能超过集合的大小。参数名称: Microsoft.DotNet.DesignTools.Client.DesignerSession.FindDesignableClass(CodeCompileUnit compileUnit)
中 System.CodeDom.CodeTypeDeclarationCollection.get_Item(Int32 index) 中 System.Collections.CollectionBase.System.Collections.IList.get_Item(Int32 index)中的索引 在 Microsoft.VisualStudio.WinForms.RemoteClient.Loader.RemoteCodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager 管理器) 在 Microsoft.VisualStudio.WinForms.RemoteClient.Loader.RemoteCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager 管理器)
在 Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
--- 从先前发生异常的位置结束堆栈跟踪 ---
在 Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager )
在 System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost 主机)
代码本身,例如 MainForm.cs
using SFP.Classes;
using SFP.Methods;
using System.Windows.Forms;
namespace SFP
{
namespace Forms
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
}
}
}
MainForm.Designer.cs
namespace SFP
{
namespace Forms
{
partial class MainForm
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором форм Windows
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.OpenDialog = new System.Windows.Forms.OpenFileDialog();
this.FormContainer = new System.Windows.Forms.Panel();
this.SuspendLayout();
//
// OpenDialog
//
this.OpenDialog.FileName = "OpenDialog";
this.OpenDialog.ReadOnlyChecked = true;
this.OpenDialog.RestoreDirectory = true;
this.OpenDialog.ShowReadOnly = true;
this.OpenDialog.SupportMultiDottedExtensions = true;
//
// FormContainer
//
resources.ApplyResources(this.FormContainer, "FormContainer");
this.FormContainer.Name = "FormContainer";
//
// MainForm
//
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.FormContainer);
this.KeyPreview = true;
this.Name = "MainForm";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ImageList MenuImagesSmall;
private System.Windows.Forms.ImageList MenuImagesLarge;
public System.Windows.Forms.OpenFileDialog OpenDialog;
private System.Windows.Forms.Panel FormContainer;
}
}
}
程序.cs
using SFP.Forms;
using System;
using System.Windows.Forms;
namespace SFP
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}
}
应用程序启动并像错误之前一样运行。
我认为相反
必须这样做
如果它不起作用,请关闭工作室。删除项目目录下的bin和obj文件夹,重新启动studio。