启动带有C#的Windows窗体时出现空白应用程序。

huangapple go评论65阅读模式
英文:

Blank app when launching a windows form with C#

问题

我正在使用Visual Studio 2022中的C#创建监控界面的接口。我编写了一个简单的代码,原始设计时构建时没有错误或警告 - 一切都正常。但当我启动应用程序时,它的主窗体出现为空白 - 只是一个什么都没有的白色窗口。

这是项目文件夹:
https://drive.google.com/file/d/1289L4kocyYrBW9FGasU6Dhxs9r1vEHN7/view?usp=sharing

请帮助我 - 这是一个学校项目。

谢谢

我尝试了所有可能的解决方案,并检查了所有设置,但问题仍然存在,尽管代码没有显示错误或警告。

英文:

I am creating an interface for monitoring using C# in Visual Studio 2022. I wrote a simple code with a primal design when I build there are no errors or warnings - everything is good. But when I launch the app, its main form appears BLANK - just a white window with nothing in it.

This is the project folder:

https://drive.google.com/file/d/1289L4kocyYrBW9FGasU6Dhxs9r1vEHN7/view?usp=sharing

Please help me - it's for a school project.

Thank you

I tried all possible solution and checked all settings and still the same problem although the codes show no errors or warnings

答案1

得分: 0

看起来 Form1 类位于自己的命名空间 PowerConsumptionMonitor 中,启动代码没有正确引用它。请修改你的 Program.cs 文件中的这行代码:

Application.Run(new Form1());

改为

Application.Run(new PowerConsumptionMonitor.Form1());
英文:

Looks like the Form1 class is in it's own namespace called PowerConsumptionMonitor, and the startup code isn't referencing it properly. Modify this line in your Program.cs file:

Application.Run(new Form1());

to

Application.Run(new PowerConsumptionMonitor.Form1());

huangapple
  • 本文由 发表于 2023年5月28日 01:10:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/76348085.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定