英文:
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());
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论