Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wpf The type name 'App' does not exist in the type ... occurs after renaming MainWindow

Tags:

wpf

In a simple WPF, I have renamed MainWindow class to MyClass and I got this error in App.g.cs:

    public static void Main() {
        MyClass.App app = new MyClass.App();
        app.InitializeComponent();
        app.Run();
    }

How can I fix this can't find anything on the internet ?

like image 557
user310291 Avatar asked Dec 18 '10 20:12

user310291


3 Answers

I accidentally got this error, in my case I had a class with the same name as the namespace. Renaming the class solved the problem.

like image 124
Johan Larsson Avatar answered Nov 01 '22 14:11

Johan Larsson


Do not name a class the same as its namespace

Check out if you don't have a class somewhere in your project that has the same name as your namespace!

for example:

namespace HashCalculator
{
  public class HashCalculator
like image 26
Legends Avatar answered Nov 01 '22 15:11

Legends


App.g.cs is produced by compiling App.xaml into C# code. The problem is in your App.xaml. Without seeing it, I can't be sure exactly what, but you probably just need to alter the StartupUri to StartupUri="MyClass.xaml".

like image 4
Tergiver Avatar answered Nov 01 '22 15:11

Tergiver