A fix for CS0426 in XAML and generated .g.cs file while building

Michael Jackson 1 Reputation point
2022-09-04T03:33:54.873+00:00

While working on a project I started debugging and out of no where a bunch of CS0426 errors came out of nowhere in the generated .g.cs files. I checked my references and I see all the assemblies referenced and added to the project already as you can see in the images. I have already tried reinstalling VS2019, restarting my computer, reinstalling/updating dotnet to 4.8 and tried a new project solution file as well.

Looking closer I do not know how it cannot find for example "Window" in "System.Windows" especially that is included in that type. All my 'usings' are in tact as well. I believe this pops up when I created multiple classes in a solution as well.

Any idea on how to fix this? I am using Visual Studio 2019 and DotNet 4.8.

237544-case.png237507-case2.png237517-case3.png

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,670 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,595 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,229 questions
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
938 questions
XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
762 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Jackson 1 Reputation point
    2022-09-09T15:23:58.713+00:00

    All fixed. I created a System.cs file and the class overwrote the using statement's reference. I just renamed the System.cs file to something else and it all works okay.

    0 comments No comments