Невозможно просмотреть мою форму в конструкторе форм

Я добавил новый класс в свой проект С#. Очень просто и на основе многих примеров, которые я нашел:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GENIO_Viewer
{
    class DBTableLayoutPanel : TableLayoutPanel
    {
        public DBTableLayoutPanel() : base()
        {
            DoubleBuffered = true;
        }
    }
}

Затем я отредактировал файл класса дизайнера, чтобы использовать измененный объект (код сокращен):

private void InitializeComponent()
{
    this.tableLayoutPanel = new DBTableLayoutPanel();
    // tableLayoutPanel
    // 
    this.tableLayoutPanel.AutoSize = true;
    this.tableLayoutPanel.BackColor = System.Drawing.Color.Black;
    this.tableLayoutPanel.ColumnCount = 1;
    this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
    this.tableLayoutPanel.Cursor = System.Windows.Forms.Cursors.Cross;
    this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
    this.tableLayoutPanel.Location = new System.Drawing.Point(0, 24);
    this.tableLayoutPanel.Name = "tableLayoutPanel";
    this.tableLayoutPanel.RowCount = 1;
    this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
    this.tableLayoutPanel.Size = new System.Drawing.Size(555, 359);
    this.tableLayoutPanel.TabIndex = 4;
}

Компилируется нормально. Но когда я перехожу к отображению формы в редакторе, у меня возникает проблема:

Ошибки

Почему это? Я не могу понять, что я должен сделать, чтобы это исправить.

Обновлять:

Это полное определение формы для файла конструктора. Это работает, только если я закомментирую строки DBTableLayoutPanel и заменю их закомментированными строками. Смущенный. :

using System;

namespace GENIO_Viewer
{
    partial class GENIO_Viewer_Form
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();

                m_moduleTD_Tb.Dispose();
                m_hostApp.Dispose();
                m_sysSrv.Dispose();

                GC.Collect();
                GC.WaitForPendingFinalizers();
                Teigha.Core.Globals.odgsUninitialize();
                Teigha.Core.Globals.odrxUninitialize();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GENIO_Viewer_Form));
            this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
            this.statusStrip1 = new System.Windows.Forms.StatusStrip();
            this.toolStripCoordinate = new System.Windows.Forms.ToolStripStatusLabel();
            this.toolStripProgressBar = new System.Windows.Forms.ToolStripProgressBar();
            this.toolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
            this.toolStripCoordinates = new System.Windows.Forms.ToolStripStatusLabel();
            //this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
            this.tableLayoutPanel = new GENIO_Viewer.DBTableLayoutPanel();
            this.menuStrip1 = new System.Windows.Forms.MenuStrip();
            this.menuFile = new System.Windows.Forms.ToolStripMenuItem();
            this.menuFile_LoadGenio = new System.Windows.Forms.ToolStripMenuItem();
            this.menuFile_SaveAutoCAD = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
            this.menuFile_RecentFile = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
            this.menuFile_Exit = new System.Windows.Forms.ToolStripMenuItem();
            this.menuView = new System.Windows.Forms.ToolStripMenuItem();
            this.menuViewCodeEditor = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
            this.menuView_ZoomExtents = new System.Windows.Forms.ToolStripMenuItem();
            this.menuView_ZoomWindow = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStrip = new System.Windows.Forms.ToolStrip();
            this.toolStripButton_ZoomWindow = new System.Windows.Forms.ToolStripButton();
            this.toolStripButton_ZoomExtents = new System.Windows.Forms.ToolStripButton();
            this.statusStrip1.SuspendLayout();
            this.menuStrip1.SuspendLayout();
            this.toolStrip.SuspendLayout();
            this.SuspendLayout();
            // 
            // toolStripButton1
            // 
            this.toolStripButton1.Name = "toolStripButton1";
            this.toolStripButton1.Size = new System.Drawing.Size(23, 23);
            // 
            // statusStrip1
            // 
            this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.toolStripCoordinate,
            this.toolStripProgressBar,
            this.toolStripStatusLabel,
            this.toolStripCoordinates});
            this.statusStrip1.Location = new System.Drawing.Point(0, 383);
            this.statusStrip1.Name = "statusStrip1";
            this.statusStrip1.Size = new System.Drawing.Size(555, 22);
            this.statusStrip1.TabIndex = 3;
            this.statusStrip1.Text = "statusStrip";
            // 
            // toolStripCoordinate
            // 
            this.toolStripCoordinate.AutoSize = false;
            this.toolStripCoordinate.Name = "toolStripCoordinate";
            this.toolStripCoordinate.Size = new System.Drawing.Size(200, 17);
            // 
            // toolStripProgressBar
            // 
            this.toolStripProgressBar.AutoSize = false;
            this.toolStripProgressBar.Name = "toolStripProgressBar";
            this.toolStripProgressBar.Size = new System.Drawing.Size(100, 16);
            // 
            // toolStripStatusLabel
            // 
            this.toolStripStatusLabel.AutoSize = false;
            this.toolStripStatusLabel.Name = "toolStripStatusLabel";
            this.toolStripStatusLabel.Size = new System.Drawing.Size(257, 17);
            this.toolStripStatusLabel.Spring = true;
            this.toolStripStatusLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            // 
            // toolStripCoordinates
            // 
            this.toolStripCoordinates.Name = "toolStripCoordinates";
            this.toolStripCoordinates.Size = new System.Drawing.Size(0, 0);
            // 
            // tableLayoutPanel
            // 
            this.tableLayoutPanel.AutoSize = true;
            this.tableLayoutPanel.BackColor = System.Drawing.Color.LightGray;
            this.tableLayoutPanel.ColumnCount = 1;
            this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
            this.tableLayoutPanel.Cursor = System.Windows.Forms.Cursors.Cross;
            this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tableLayoutPanel.Location = new System.Drawing.Point(0, 24);
            this.tableLayoutPanel.Name = "tableLayoutPanel";
            this.tableLayoutPanel.RowCount = 1;
            this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
            this.tableLayoutPanel.Size = new System.Drawing.Size(555, 359);
            this.tableLayoutPanel.TabIndex = 4;
            // 
            // menuStrip1
            // 
            this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.menuFile,
            this.menuView});
            this.menuStrip1.Location = new System.Drawing.Point(0, 0);
            this.menuStrip1.Name = "menuStrip1";
            this.menuStrip1.Size = new System.Drawing.Size(555, 24);
            this.menuStrip1.TabIndex = 5;
            this.menuStrip1.Text = "menuStrip1";
            // 
            // menuFile
            // 
            this.menuFile.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.menuFile_LoadGenio,
            this.menuFile_SaveAutoCAD,
            this.toolStripSeparator1,
            this.menuFile_RecentFile,
            this.toolStripSeparator2,
            this.menuFile_Exit});
            this.menuFile.Name = "menuFile";
            this.menuFile.Size = new System.Drawing.Size(37, 20);
            this.menuFile.Text = "&File";
            this.menuFile.DropDownOpening += new System.EventHandler(this.menuFile_DropDownOpening);
            // 
            // menuFile_LoadGenio
            // 
            this.menuFile_LoadGenio.Name = "menuFile_LoadGenio";
            this.menuFile_LoadGenio.Size = new System.Drawing.Size(172, 22);
            this.menuFile_LoadGenio.Text = "Load GENIO File";
            this.menuFile_LoadGenio.Click += new System.EventHandler(this.menuFile_LoadGenio_Click);
            // 
            // menuFile_SaveAutoCAD
            // 
            this.menuFile_SaveAutoCAD.Name = "menuFile_SaveAutoCAD";
            this.menuFile_SaveAutoCAD.Size = new System.Drawing.Size(172, 22);
            this.menuFile_SaveAutoCAD.Text = "Save AutoCAD File";
            this.menuFile_SaveAutoCAD.Click += new System.EventHandler(this.menuFile_SaveAutoCAD_Click);
            // 
            // toolStripSeparator1
            // 
            this.toolStripSeparator1.Name = "toolStripSeparator1";
            this.toolStripSeparator1.Size = new System.Drawing.Size(169, 6);
            // 
            // menuFile_RecentFile
            // 
            this.menuFile_RecentFile.Name = "menuFile_RecentFile";
            this.menuFile_RecentFile.Size = new System.Drawing.Size(172, 22);
            this.menuFile_RecentFile.Text = "Recent File";
            // 
            // toolStripSeparator2
            // 
            this.toolStripSeparator2.Name = "toolStripSeparator2";
            this.toolStripSeparator2.Size = new System.Drawing.Size(169, 6);
            // 
            // menuFile_Exit
            // 
            this.menuFile_Exit.Name = "menuFile_Exit";
            this.menuFile_Exit.Size = new System.Drawing.Size(172, 22);
            this.menuFile_Exit.Text = "E&xit";
            this.menuFile_Exit.Click += new System.EventHandler(this.menuFile_Exit_Click);
            // 
            // menuView
            // 
            this.menuView.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.menuViewCodeEditor,
            this.toolStripSeparator3,
            this.menuView_ZoomExtents,
            this.menuView_ZoomWindow});
            this.menuView.Name = "menuView";
            this.menuView.Size = new System.Drawing.Size(44, 20);
            this.menuView.Text = "&View";
            this.menuView.DropDownOpening += new System.EventHandler(this.menuView_DropDownOpening);
            // 
            // menuViewCodeEditor
            // 
            this.menuViewCodeEditor.Name = "menuViewCodeEditor";
            this.menuViewCodeEditor.Size = new System.Drawing.Size(153, 22);
            this.menuViewCodeEditor.Text = "Code Editor";
            this.menuViewCodeEditor.Click += new System.EventHandler(this.menuViewCodeEditor_Click);
            // 
            // toolStripSeparator3
            // 
            this.toolStripSeparator3.Name = "toolStripSeparator3";
            this.toolStripSeparator3.Size = new System.Drawing.Size(150, 6);
            // 
            // menuView_ZoomExtents
            // 
            this.menuView_ZoomExtents.Name = "menuView_ZoomExtents";
            this.menuView_ZoomExtents.Size = new System.Drawing.Size(153, 22);
            this.menuView_ZoomExtents.Text = "Zoom &Extents";
            this.menuView_ZoomExtents.Click += new System.EventHandler(this.menuView_ZoomExtents_Click);
            // 
            // menuView_ZoomWindow
            // 
            this.menuView_ZoomWindow.Name = "menuView_ZoomWindow";
            this.menuView_ZoomWindow.Size = new System.Drawing.Size(153, 22);
            this.menuView_ZoomWindow.Text = "Zoom &Window";
            this.menuView_ZoomWindow.Click += new System.EventHandler(this.menuView_ZoomWindow_Click);
            // 
            // toolStrip
            // 
            this.toolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.toolStripButton_ZoomWindow,
            this.toolStripButton_ZoomExtents});
            this.toolStrip.Location = new System.Drawing.Point(0, 24);
            this.toolStrip.Name = "toolStrip";
            this.toolStrip.Size = new System.Drawing.Size(555, 25);
            this.toolStrip.TabIndex = 6;
            this.toolStrip.Text = "toolStrip";
            // 
            // toolStripButton_ZoomWindow
            // 
            this.toolStripButton_ZoomWindow.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.toolStripButton_ZoomWindow.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton_ZoomWindow.Image")));
            this.toolStripButton_ZoomWindow.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton_ZoomWindow.Name = "toolStripButton_ZoomWindow";
            this.toolStripButton_ZoomWindow.Size = new System.Drawing.Size(23, 22);
            this.toolStripButton_ZoomWindow.Text = "Zoom Window";
            this.toolStripButton_ZoomWindow.Click += new System.EventHandler(this.toolStripButton_ZoomWindow_Click);
            // 
            // toolStripButton_ZoomExtents
            // 
            this.toolStripButton_ZoomExtents.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.toolStripButton_ZoomExtents.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton_ZoomExtents.Image")));
            this.toolStripButton_ZoomExtents.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton_ZoomExtents.Name = "toolStripButton_ZoomExtents";
            this.toolStripButton_ZoomExtents.Size = new System.Drawing.Size(23, 22);
            this.toolStripButton_ZoomExtents.Text = "Zoom Extents";
            this.toolStripButton_ZoomExtents.Click += new System.EventHandler(this.toolStripButton_ZoomExtents_Click);
            // 
            // GENIO_Viewer_Form
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(555, 405);
            this.Controls.Add(this.toolStrip);
            this.Controls.Add(this.tableLayoutPanel);
            this.Controls.Add(this.statusStrip1);
            this.Controls.Add(this.menuStrip1);
            this.Cursor = System.Windows.Forms.Cursors.Default;
            this.DoubleBuffered = true;
            this.MainMenuStrip = this.menuStrip1;
            this.Name = "GENIO_Viewer_Form";
            this.Text = "GENIO Viewer";
            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.GENIO_Viewer_Form_FormClosing);
            this.Load += new System.EventHandler(this.GENIO_Viewer_Form_Load);
            this.statusStrip1.ResumeLayout(false);
            this.statusStrip1.PerformLayout();
            this.menuStrip1.ResumeLayout(false);
            this.menuStrip1.PerformLayout();
            this.toolStrip.ResumeLayout(false);
            this.toolStrip.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.ToolStripButton toolStripButton1;
        private System.Windows.Forms.StatusStrip statusStrip1;
        private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel;
        private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar;
        //private System.Windows.Forms.TableLayoutPanel tableLayoutPanel;
        private GENIO_Viewer.DBTableLayoutPanel tableLayoutPanel;
        private System.Windows.Forms.MenuStrip menuStrip1;
        private System.Windows.Forms.ToolStripMenuItem menuFile;
        private System.Windows.Forms.ToolStripMenuItem menuView;
        private System.Windows.Forms.ToolStripMenuItem menuView_ZoomExtents;
        private System.Windows.Forms.ToolStripMenuItem menuView_ZoomWindow;
        private System.Windows.Forms.ToolStripMenuItem menuFile_LoadGenio;
        private System.Windows.Forms.ToolStripMenuItem menuFile_SaveAutoCAD;
        private System.Windows.Forms.ToolStrip toolStrip;
        private System.Windows.Forms.ToolStripButton toolStripButton_ZoomWindow;
        private System.Windows.Forms.ToolStripButton toolStripButton_ZoomExtents;
        private System.Windows.Forms.ToolStripStatusLabel toolStripCoordinates;
        private System.Windows.Forms.ToolStripStatusLabel toolStripCoordinate;
        private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
        private System.Windows.Forms.ToolStripMenuItem menuFile_RecentFile;
        private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
        private System.Windows.Forms.ToolStripMenuItem menuFile_Exit;
        private System.Windows.Forms.ToolStripMenuItem menuViewCodeEditor;
        private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
    }
}

Обновление: это также происходит, когда я наследую DataGridView и устанавливаю DoubleBuffered. Делает редактор неработоспособным. ????


person Andrew Truckle    schedule 05.06.2016    source источник
comment
Вы пытались закрыть все дизайнеры, а затем очистить и перестроить решение и снова открыть дизайнер?   -  person Reza Aghaei    schedule 05.06.2016
comment
Спасибо за предложение. Похоже, это не решило.   -  person Andrew Truckle    schedule 06.06.2016
comment
Если простая очистка и перестроение решения или повторное открытие Visual Studio и перестроение после удаления bin и obj не решили проблему, взгляните на этот вопрос и ответьте Не удается просмотреть конструктор при кодировании формы на C# Этот вопрос и ответ могут оказаться полезными.   -  person Reza Aghaei    schedule 06.06.2016
comment
@RezaAghaei Я тоже не могу решить этот вопрос по этой ссылке. :(   -  person Andrew Truckle    schedule 06.06.2016
comment
Эта ссылка не решает проблему напрямую. Но делится важной и интересной информацией о том, как работает конструктор. Имея такую ​​информацию, обычно можно решить проблемы дизайнера.   -  person Reza Aghaei    schedule 06.06.2016
comment
Я ценю это, но я все еще сталкиваюсь с проблемой. Что менять мне непонятно. Я также изучил файл CSPROJ.   -  person Andrew Truckle    schedule 06.06.2016
comment
эта проблема в основном возникает, когда вы добавляете элемент управления в форму, а также добавляете событие в код позади, но позже вы изменяете или удаляете код из кода, и в дизайнере ссылка существует, лучшее решение для этого - проверить недавно работающую форму и удалить код один за другим и тест   -  person Nazir Ullah    schedule 10.06.2016
comment
удалите код панели таблицы и добавьте снова, затем попробуйте   -  person Nazir Ullah    schedule 10.06.2016
comment
Я только что попробовал это. Нет радости. Но я могу создать новый проект, перетащить его, и все в порядке. Может быть, мне нужно пересоздать весь проект?   -  person Andrew Truckle    schedule 11.06.2016
comment
@NazirUllah Пожалуйста, посмотрите мой ответ.   -  person Andrew Truckle    schedule 12.06.2016


Ответы (1)


Я столкнулся с этим вопросом:

Невозможно разместить пользовательский элемент управления на форме

В одном из ответов говорилось об изменении режима сборки. Я установил для него x64 битовый режим сборки из-за файлов DLL, от которых зависит мое приложение. Если установлено значение Любой процессор, я получаю следующие ошибки сборки:

//1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "TD_SwigCoreMgd, Version=4.1.0.0, Culture=neutral, PublicKeyToken=8e28356228e490a2, processorArchitecture=AMD64", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
//1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "TD_SwigDbMgd, Version=4.1.0.0, Culture=neutral, PublicKeyToken=5ccc28765cdf0a88, processorArchitecture=AMD64", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
//1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "TG_SwigDbMgd, Version=4.1.0.0, Culture=neutral, PublicKeyToken=65e973a5aff9b959, processorArchitecture=AMD64", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.

Поэтому мне пришло в голову снова установить приложение на любой процессор, выполнить очистку и перестроить, и вуаля, теперь я могу редактировать свои формы. Но после этого я должен снова установить его на x64. Это раздражает. Но я не вижу другого выхода.

person Andrew Truckle    schedule 12.06.2016