c# - 运行应用程序时 Visual Studio 不显示 UI
解决方案
要测试的两件事:
在代码文件
Program.cs
中,您会发现如下内容:static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }
该行
Application.Run
中的表单名称是否与您的表单名称匹配?您的表单代码(Form1.cs)应该有一个如下所示的构造函数
public Form1() // Where the name of the constructor must match the one of the form class. { InitializeComponent(); // Your code goes here (if any) ... }
它有这个构造函数吗?如果是,它会调用
InitializeComponent
吗?
InitializeComponent
非常重要,因为它创建控件并配置表单。您可能已将其替换为您自己的代码。始终在初始化代码之前调用它。
推荐阅读
- docker - 通过 Docker API 将私有镜像推送到 Docker Registry
- python - @ 提到在 python 中使用 simple_salesforce 的喋喋不休请求 SFDC
- c# - 在 C# 中反序列化 JSON 文件
- javascript - javascript 不断从 python var 返回 NaN%
- visual-studio - 使用 Beyond Compare 与 Visual Studio 的 Bitbucket 扩展来查看拉取请求?
- rpgle - 通过 RegEx 检查 Genexus RPG 中的字符串
- unity3d - GVRReticlePointer 无法与 onClick 事件一起正常工作
- oracle - Oracle v$archive_gap 返回未选择的行
- arrays - 如何在 SAS 的数组索引中使用列的值
- php - 使用 PHP 更新外键值