Has more than one entry point defined error

后端 未结 2 836
情话喂你
情话喂你 2021-01-24 17:07

I have the following code:

namespace WpfApplication2
{
    /// 
    /// Interaction logic for MainWindow.xaml
    /// 
    public p         


        
相关标签:
2条回答
  • 2021-01-24 17:51

    You have two primary options to implement on start activities:

    Event handlers

    File App.xaml

    <Application x:Class="CSharpWPF.App"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 StartupUri="MainWindow.xaml"
                 Startup="Application_Startup">
    

    Define Startup="Application_Startup" and handle in file App.xaml.cs:

        private void Application_Startup(object sender, StartupEventArgs e)
        {
            // On start stuff here
        }
    

    Override method

    File App.xaml.cs

    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            // On start stuff here
            base.OnStartup(e);
    
            // Or here, where you find it more appropriate
        }
    }
    
    0 讨论(0)
  • 2021-01-24 17:52

    In order to solve this error, don't change the name of the .cs file when creating new code.

    If you want a new name for your .cs file then you have to delete everything in the folder where your project is i.e., the fragments of files (bin, obj folders, etc.).

    0 讨论(0)
提交回复
热议问题