I'm trying to create a wpf project without using auto generate files in VS2010, I thought it would help me to get a better understanding so I hope this won't sound super primitive question.
Anyway, after making the xaml file and its code behind e.g. myWindow.xaml and myWindow.xaml.cs I also created App.xaml and its code behind.
Things seems OK till I ran the code and got this message:
'test1.exe' does not contain a static 'Main' method suitable for an entry point
Here is what I have by far:
<Application x:Class="test1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="myWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
namespace test1
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public App()
{
InitializeComponent();
}
}
}
Then have
<Window x:Class="test1.myWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
>
<Grid>
</Grid>
</Window>
namespace test1
{
/// <summary>
/// Interaction logic for myWindow.xaml
/// </summary>
public partial class myWindow : Window
{
public myWindow()
{
InitializeComponent();
}
}
}
could be due to wrong BAML files being generated here? since Main() usually gets placed during build process.
But WPF without XAML is possible. You don't even need Visual Studio installed for this, just the . NET CLI and the Developer Command Prompt. Drop these two files in a folder and run msbuild and then you can run the file in the Bin directory.
None of Microsoft's GUI frameworks ever really die. WPF has top-notch performance, with a high level of customization, and if you aim for Windows, both WPF is critical. Caliburn and ReactiveUI prove that WPF still has a rich ecosystem around it, and it is here to stay.
It was in 2006 that Windows Presentation Foundation (WPF) was released with . NET framework 3.0. Over the years it got improved and it is still now in the market in 2021.
The Build Action of your App.xaml needs to be set to "ApplicationDefinition" to have Main generated for you. It's probably set to "Page", the default for XAML files. Look in the Properties when the App.xaml file is selected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With