성태의 닷넷 이야기
작은 글씨
큰 글씨
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] Why is the name of the Microsoft Wi...
[정성태] 기존의 In-proc COM 개체를 surrogate 프로세스에...
[정성태] Announcing the Oracle Database Vect...
[정성태] 온라인에서 우연히 printf 계열의 format specifi...
[정성태] Hardware backwards compatibility ;...
[정성태] 10 Modern Commands for Your Termina...
[정성태] File-based App을 VSCode에서 쉽게 실행할 수 있...
[정성태] 저도 소켓은 꽤나 테스트를 하면서 진행을 하곤 합니다. 경험으로...
[정해성] 답변 감사합니다. 며칠 동안 검색도 해보고 GPT 에게도 물어봤...
[정성태] 1. 문서에도 나오지만 blocking 모드에서는 그런 경우가 ...
글쓰기
제목
이름
암호
전자우편
HTML
홈페이지
유형
제니퍼 .NET
닷넷
COM 개체 관련
스크립트
VC++
VS.NET IDE
Windows
Team Foundation Server
디버깅 기술
오류 유형
개발 환경 구성
웹
기타
Linux
Java
DDK
Math
Phone
Graphics
사물인터넷
부모글 보이기/감추기
내용
<div style='display: inline'> <h1 style='font-family: Malgun Gothic, Consolas; font-size: 20pt; color: #006699; text-align: center; font-weight: bold'>Windows Forms 디자이너 - The class Form1 can be designed, but is not the first class in the file.</h1> <p> 다음과 같은 질문이 있군요,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > C# Winform 작업을 하다가 처음 보는 오류를 접했습니다 ; <a target='tab' href='https://forum.dotnetdev.kr/t/c-winform/1219'>https://forum.dotnetdev.kr/t/c-winform/1219</a> </pre> <br /> 그러니까, 갑자기 Form 디자인 화면이 다음과 같은 오류를 겪는 현상입니다.<br /> <br /> <img onclick='toggle_img(this)' class='imgView' alt='winform_design_first_class_1.png' src='/SysWebRes/bbs/winform_design_first_class_1.png' /><br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > 클래스 Form1은(는) 디자인 가능하지만 파일의 첫 번째 클래스가 아닙니다. Visual Studio에서 디자이너는 파일의 첫 번째 클래스를 사용해야 합니다. 파일에서 첫 번째 클래스가 되도록 해당 클래스 코드를 이동한 다음 디자이너를 다시 로드하십시오. </pre> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > The class Form1 can be designed, but is not the first class in the file. Visual Studio requires that designers use the first class in the file. Move the class code so that it is the first class in the file and try loading the designer again. at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager manager) at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager) at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager) --- End of stack trace from previous location where exception was thrown --- at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager) at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host) </pre> <br /> 원인은 (사실 오류 메시지에서 잘 설명하고 있지만) 의외로 간단합니다. 비주얼 스튜디오의 Form 디자인 화면은 기본적으로 해당 cs 파일에 정의된 첫 번째 클래스를 디자인 대상으로 찾기 때문입니다. 그래서 다음과 같은 식으로 또 다른 클래스를 Form 클래스 이전에 작성하면,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > using System.Windows.Forms; namespace WindowsFormsApp1 { <span style='color: blue; font-weight: bold'>public class MyType</span> { public int Age; } <span style='color: blue; font-weight: bold'>public partial class Form1 : Form</span> { public Form1() { InitializeComponent(); } } } </pre> <br /> 문제가 되는 것입니다. 따라서, 이것을 우회하려면 다음과 같이 위치를 옮기면 됩니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > using System.Windows.Forms; namespace WindowsFormsApp1 { <span style='color: blue; font-weight: bold'>public partial class Form1 : Form</span> { public Form1() { InitializeComponent(); } } <span style='color: blue; font-weight: bold'>public class MyType</span> { public int Age; } } </pre> </p><br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
1472
(왼쪽의 숫자를 입력해야 합니다.)