Removed App.xml and App.xml.cs files

Silly, I deleted the App.xml and App.xml.cs files by mistake.

I can recreate these files as I am using the source control (a bit outdated unfortunately), however, when I recreate these files and add them back to my project, VS cannot build the project because I am told that I do not have entry points.

My workaround is to create a load class with the "Main" keyword to write the application and associate with the project, however what is the correct procedure to recreate and relink the App.xml and App.xml.cs files in VS in my project.

Many thanks.

+3


source to share


1 answer


Your question intrigued me, so I created a new project and blew away the files App.xaml

and App.xaml.cs

. Then I added the window to the project and changed its build action in the file properties editor to ApplicationDefinition

from Page

, then changed the files xaml

and xaml.cs

to the application class. After that, it worked correctly.

i.e.

App.xaml



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

    </Application.Resources>
</Application>

      

App.xaml.cs

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;


namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application 
    {

    }
}

      

+3


source







All Articles