VS2010 中的 WPF 项目文件隐藏的 Main() 函数在哪里?
可能的重复:
WPF 中没有 Main() 吗?
这是 WPF 编程中 Main() 的代码。
[STAThread]
public static void Main()
{
Window win = new Window();
....
Application app = new Application();
app.Run(win);
}
然而,当我尝试使用VS2010制作WPF应用程序时。
我找不到 Main(),但是 public MainWindow()
。
为什么 Main() 函数被隐藏?当我使用VS2010 WPF项目时,如何获取Main()?
Possible Duplicate:
No Main() in WPF?
This is the code for Main() in WPF programming.
[STAThread]
public static void Main()
{
Window win = new Window();
....
Application app = new Application();
app.Run(win);
}
However, when I tried to use VS2010 to make WPF Application.
I can't find the Main(), but public MainWindow()
.
Why is the Main() function hidden? How can I get the Main() when I use VS2010 WPF project?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它位于 .\obj\BuildConfiguration\app.g.cs
您可以通过打开 app.xaml.cs 轻松导航到它,并使用源代码上方的右侧组合框来选择(灰色=驻留在另一个部分类文件中)主要方法。
It is in .\obj\BuildConfiguration\app.g.cs
You can easily navigate to it by opening app.xaml.cs and use the right combobox above the source code to select the (grayed = resides in another partial-class file) main method.
入口点位于 App.xaml.cs 中。在那里,您还可以覆盖 OnStartup 并传入命令行参数(如果您想要这样做)。
正如其他人提到的,此处的问题回答了您的需求。
The entry point is in App.xaml.cs. In there you could also override the OnStartup and pass in the cmd line arguments, if thats what you were wanting to do.
As others have mentioned, the question here answers what you are after.
Main()是编译时生成的,在obj/{Debug,Release}文件夹下的App.g.cs中找到
Main() is generated during compilation.Find it in App.g.cs in obj/{Debug,Release} folder