ERROR INITIALIZECOMPONENT

FluxuRate 50 Reputation points
2023-07-26T21:35:17.5533333+00:00

Hello, good morning, I have been compiling a code in .Net Maui, I have added a SplashScreen and in the C# code of the content page in which the SplashScreen is stored, it gives me the CS0103 error with the InitializedComponent, here is part of the code and a capture of the project would be of great help to solve it:

SplashScreenPage.xaml:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
              x:Class="MAUIAPP.SplashScreenPage"
              BackgroundColor="White">
     <StackLayout VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand">
         <!-- Add your splash screen content here -->
         <Image Source="splash_image.jpg" HeightRequest="100" WidthRequest="100" />
         <Label Text="MAUI App Splash Screen" FontSize="24" />
     </StackLayout>
</ContentPage>

SplashScreenPage.xaml.cs:

using Microsoft.Maui.Controls;
namespace MAUIAPP
{
     public partial class SplashScreenPage : ContentPage
     {
         public SplashScreenPage()
         {
             InitializeComponent();
         }
       
     }
}

I get the following error: Severity Code Description Project File Line Suppression State

Error CS0103 The name 'InitializeComponent' does not exist in the current context MAUIAPP (net7.0-android), MAUIAPP (net7.0-ios), MAUIAPP (net7.0-maccatalyst), MAUIAPP (net7.0-windows10.0.19041 .0) F:\App Gestorias\MAUIAPP\MAUIAPP\SplashScreenPage.xaml.cs 9 Activate

I will leave here a screenshot of the project :)

Capture

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,506 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,932 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Timothy Hobbs 0 Reputation points
    2023-09-12T15:25:01.26+00:00

    I got this error because the code I pulled referred to a local download of the nuget package (using "hint") and not referencing the CommunityToolkit.Maui from Nuget

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.