Reputation: 1
How to fix this :
CS0161 'MauiProgram.CreateMauiApp()': not all code paths return a value
I dont see what i'm doing wrong, can you please assist? Thank you!
PS: Im on realy begining level so Im sorry if I didnt seen solution that can be very simple but Im to stupid right now to solve it by myself.
namespace LoginApp;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
}
}
I was searching on other forums etc. but I didint found answear for my porblem.
Upvotes: 0
Views: 276
Reputation: 89179
in C# if a method has a non-void return type it means that the method must return an instance of that type.
Which in this case:
public static MauiApp CreateMauiApp()
It is of type MauiApp
. If you look at the default CreateMauiApp
method created by the template, the last line is
return builder.Build();
Upvotes: 2