'MvxWpfSetup<App>' must be a non-abstract type with a public parameterless constructor

Viewed 1222

I'm trying to follow the code at the end of this video here, but I'm getting this error around the 1:11:10 mark:

error CS0310: 'MvxWpfSetup<App>' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'TMvxSetup' in the generic type or method 'MvxSetupExtensions.RegisterSetupType<TMvxSetup>(object, params Assembly[])'

I really have no idea what code is relevant, but this is the file thats giving the error:

using MvvmCross.Core;
using MvvmCross.Platforms.Wpf.Core;
using MvvmCross.Platforms.Wpf.Views;

namespace MvxStarter.Wpf
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : MvxApplication
    {
        protected override void RegisterSetup()
        {
            this.RegisterSetupType<MvxWpfSetup<MvxStarter.Core.App>>();
        }
    }
}

I went over this whole section multiple times and I'm pretty certain I have exactly what he has. I even downloaded his source code, but I couldnt open the project so I copied and pasted all the code and I'm still getting this error. What should I do? I can post more relevant code if you tell me what to post. I have no idea what this error means and nothing I can find online about it makes any sense.

edit: I tried following the official documentation example project and I got the exact same error on the exact same line. Is something wrong with my installation? https://www.mvvmcross.com/documentation/tutorials/tipcalc/the-core-project https://www.mvvmcross.com/documentation/tutorials/tipcalc/a-wpf-ui-project

3 Answers

Need to create Setup class so code becomes. using MvvmCross.Core; using MvvmCross.Platforms.Wpf.Core;

using MvvmCross.Platforms.Wpf.Views;

namespace MvxStarter.Wpf
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : MvxApplication
    {
        protected override void RegisterSetup()
        {
            this.RegisterSetupType<Setup>();
        }
    }
}

Then Setup becomes

namespace MvxStarter.Wpf
{
    public class Setup : MvxWpfSetup<Core.App>
    {
        protected override ILoggerProvider CreateLogProvider()
        {
            return new SerilogLoggerProvider();
        }

        protected override ILoggerFactory CreateLogFactory()
        {
            Log.Logger = new LoggerConfiguration()
                .MinimumLevel.Debug()
                .CreateLogger();

            return new SerilogLoggerFactory();
        }
    }
}

or similar. This used Nuget Serilog as well as others.

Related