首页 文章

WPF没有入口点

提问于
浏览
-2

我正在使用 SharpDevelop 并且通过我的错误将 App.xaml 移动到子目录 .

当我尝试启动/调试应用程序时,C#说,我的应用程序没有入口点或静态主方法(CS5001) .

Edit < Undo 或默认主文件夹的movint将无法使用 .

怎么了?

Edit 在项目设置中,不会侦听任何类/方法:
enter image description here

App.xaml

<Application x:Class="SongManager.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Startup="Boot"> </Application>

App.xaml.cs

using System;
using System.Windows;
using SmuleTools;

namespace SongManager {
    public partial class App : Application {
        private Account user;

        public App() {

        }

        public Account getAccount() {
            return this.user;
        }

        [STAThread]
        private void Boot(object sender, StartupEventArgs e) {
            Login login = new Login();

            login.AuthSuccess((Object result) => {
                this.user       = (Account) result;
                Manager window  = new Manager(this);
                window.Show();
                login.Close();
            });

            login.Show();
        }
    }
}

2 回答

  • 0

    尝试在 App 类中添加 Main() 方法:

    [STAThread]
    public static void Main()
    {
        App application = new App();
        application.Run();
    }
    

    默认情况下,构建应用程序时应生成一个 .

  • 0

    解决方案有点棘手,但 easy .

    移动主 .xaml 文件后, Build action 将丢失 - 这些是项目/编译器设置中的 not

    Step-by-Step:

    • (red mark) 单击 .xaml 文件(示例, App.xaml

    • (blue mark) 转到 Properties 窗口(右侧!)

    • (green mark)Other > Build action 更改为 ApplicationDefinition

    Screenshot

    enter image description here

    这就对了!

相关问题