'Getting many errors and warnings just after creating a dotnet wpf project from the terminal
I was going to create my first wpf project and I ran the command dotnet new wpf -o gui and the folder was created but when I opened some of the files I started getting many errors. Here is the list-:
- App.xaml.cs-
The type or namespace name 'Application' could not be found (are you missing a using directive or an assembly reference?) [c#]
- AssemblyInfo.cs-
The type or namespace name 'ThemeInfoAttribute' could not be found (are you missing a using directive or an assembly reference?) [c#]
The type or namespace name 'ThemeInfo' could not be found (are you missing a using directive or an assembly reference?) [c#]
The name 'ResourceDictionaryLocation' does not exist in the current context [c#]
The name 'ResourceDictionaryLocation' does not exist in the current context [c#]
- MainWindow.xaml.cs-
The type or namespace name 'Controls' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) [c#]
The type or namespace name 'Data' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) [c#]
The type or namespace name 'Documents' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) [c#]
The type or namespace name 'Media' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) [c#]
The type or namespace name 'Media' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) [c#]
The type or namespace name 'Navigation' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) [c#]
The type or namespace name 'Shapes' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) [c#]
The type or namespace name 'Window' could not be found (are you missing a using directive or an assembly reference?) [c#]
The name 'InitializeComponent' does not exist in the current context [c#]
When I build and run the program it works fine. Please tell me how to fix these errors.
Here is the code in App.Xaml.cs-
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace gui
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
Solution 1:[1]
Sometimes Visual Studio is going crazy. Try to turn off and on this program and see if you still have this errors. Also copy and paste the code from the App.xaml.cs so we can see what's there.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ouflak |
