Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

FreshMVVM: No default constructor exception on PageModel constructor injection

$
0
0

Hey there, getting a missing method exception when trying to create a new page using FreshMVVM.

System.MissingMethodException: Default constructor not found for type InContext.Kemosabe.UI.ViewModels.ProjectSelectionPageModel

This is the PageModel:

public class ProjectSelectionPageModel : FreshBasePageModel
{
    private readonly IProjectService _projectService;
    public ProjectSelectionPageModel(IProjectService projectService)
    {
        _projectService = projectService;
    }
}

The IProjectService is registered on App start and the code works if I add this constructor to ProjectSelectionPageModel:
public ProjectSelectionPageModel() : this(FreshIOC.Container.Resolve<IProjectService>()) { }

So that is does the resolution in the construction. However, I want to do constructor injection and FreshMVVM claims to handle this.

As a note, the page is being created by this call: FreshPageModelResolver.ResolvePageModel<ProjectSelectionPageModel>(clientId);
Though the same issue is seen with the PushPageModel call.`

What am I missing?


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>