我正在尝试创建一个不使用VS2010中的自动生成文件的wpf项目,我认为它可以帮助我更好地理解,所以我希望这听起来不是超级原始的问题.
无论如何,在将xaml文件及其代码放在例如myWindow.xaml和myWindow.xaml.cs之后,我还创建了App.xaml及其代码.
在我运行代码并收到此消息之前,事情似乎还可以:
'test1.exe'不包含适用于入口点的静态'Main'方法
这是我到目前为止:
<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();
}
}
}
Run Code Online (Sandbox Code Playgroud)
然后有
<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();
}
}
}
Run Code Online (Sandbox Code Playgroud)
可能是由于这里生成了错误的BAML文件?因为Main()通常在构建过程中被放置.
需要将App.xaml的Build Action设置为"ApplicationDefinition",以便为您生成Main.它可能设置为"Page",XAML文件的默认值.选择App.xaml文件时查看属性.
| 归档时间: |
|
| 查看次数: |
138 次 |
| 最近记录: |