I am working on a WPF project on VS Community 2022 17.3.4. The problem is, even though the build is successful and the project can be run. The errors that are present are all in the code behind (being the NotesWindow.xaml.cs file of a certain page NotesWindow.xaml):
- "The name 'InitializeComponent' does not exist in the current context"
- "The name 'contentRichTextBox' does not exist in the current context"
I got curious, so I looked into the members of the Window.xaml.cs class on the dropdown menu in the Solution Explorer: Screenshot
The "contentRichTextBox" is not listed there. I clicked on one of the members to open the "NotesWindow.g.i.cs" file in order to see if "contentRichTextBox" has been defined there, but to my surprise, the code is incomplete in the file.
#pragma checksum "..\..\..\..\View\NotesWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "AEC9582938BC905BD31B1E667155FE0EF71AA569" //------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------
using EvernoteAgain.View;
using EvernoteAgain.View.User_Controls; using EvernoteAgain.ViewModel; using Microsoft.Xaml.Behaviors; using Microsoft.Xaml.Behaviors.Core; using Microsoft.Xaml.Behaviors.Input; using Microsoft.Xaml.Behaviors.Layout; using Microsoft.Xaml.Behaviors.Media; using System; using System.Diagnostics; using System.Windows; using System.Windows.Automation; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Controls.Ribbon; 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 EvernoteAgain.View {
/// <summary>
/// NotesWindow
/// </summary>
public partial class NotesWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector {
#line 30 "..\..\..\..\View\NotesWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBlock statusTextBlock;
#line default
#line hidden
#line 76 "..\..\..\..\View\NotesWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Primitives.ToggleButton boldButton;
#line default
#line hidden
#line 79 "..\..\..\..\View\NotesWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Primitives.ToggleButton italicButton;
#line default
#line hidden
#line 82 "..\..\..\..\View\NotesWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Primitives.ToggleButton underlineButton;
#line default
#line hidden
#line 85 "..\..\..\..\View\NotesWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.ComboBox fontFamilyComboBox;
#line default
#line hidden
#line 87 "..\..\..\..\View\NotesWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.ComboBox fontSizeComboBox;
#line default
#line hidden
#line 90 "..\..\..\..\View\NotesWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Button saveButton;
#line default
#line hidden
#line 94 "..\..\..\..\View\Not
Line 94 is where the "contentRichTextBox" is in the NotesWindow.xaml file. While the NotesWindow.g.i.cs file is opened, if I build the project, there are more error warnings:
- Newline in constant
- } expected (two times)
- 'Notes Window' does not implement interface member 'IComponentConnector.Connect(int, object)'
- 'Notes Window' does not implement interface member 'IComponentConnector.InitializeComponent()'
The project can be run despite the error warnings. However, firstly, they are bothering me, and secondly, I certainly don't hope they are going to become worse when the project gets more complicated with more windows etc.
Anybody have a tip for me as to why this is happening and how I can make the error warnings go away?