Reputation: 1255
When I create new WPF stand-alone app from template in VS 2013, I could not start it in debug for this exception.
error CS5001: Program 'XYZ' does not contain a static 'Main' method suitable for an entry point. The command exited with code 1.
Although I checked out if App.xaml is build as ApplicationDefinition = true, project is with 'Windows Application' output type, I reinstall all templates from command line, I am running brand new (reinstalled) VS 2013 with .net 4.5 and all project templates seems to be okay. And problem still occurs.
Anybody else is having this one too? There are similar questions with answers but no one did help me. So it's not a duplication (moderators).
I did not want to create new thread for answers but after moderators down vote and delete this question in similar thread I had to.
Upvotes: 3
Views: 4377
Reputation: 3373
Your application must contain App.xaml.cs file in project code directory such as this
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace Lab2
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
and in the child directory with path obj\(Debug or Release)\
the files with names (App.i.g.cs) (App.g.cs) with content like this
#pragma checksum "..\..\App.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "E9A260C0E00B01D8D305634A08B2F0E3"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.17929
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;
namespace Lab2 {
/// <summary>
/// App
/// </summary>
public partial class App : System.Windows.Application {
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public void InitializeComponent() {
#line 4 "..\..\App.xaml"
this.StartupUri = new System.Uri("View/MainWindow.xaml", System.UriKind.Relative);
#line default
#line hidden
}
/// <summary>
/// Application Entry Point.
/// </summary>
[System.STAThreadAttribute()]
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public static void Main() {
Lab2.App app = new Lab2.App();
app.InitializeComponent();
app.Run();
}
}
}
the solution of the problem can be find in No Main() in WPF?
Upvotes: 2