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

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 ?


Solution 1:

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.

Solution 2:

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