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

Developer technologies | .NET | .NET MAUI
Developer technologies | C#
{count} vote

2 answers

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

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

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.