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.
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.