Skip to content

Setup.Maui IoC.Get<IService>(); doesn't work in the sample project in the 5.0.181-beta repository: ""No parameterless constructor defined for type 'Setup.Maui.Services.IService". #996

Description

@sethom

Calling IoC.Get() from a ViewModel, throws the following exception: "No parameterless constructor defined for type 'Setup.Maui.Services.IService".

Steps to reproduce:

Change Setup.Maui project file to use 8.0.92

Remove assembly references to local Caliburn.Micro.Maui dll.
Caliburn.Micro.Maui package, version 5.0.151-beta from Nuget

Add the following code to the MainViewModel class:

private IService _theService;
public void OnCounterClicked()
{
_theService = IoC.Get<IService>();
count++;
}

If I call IoC.Get() it works. However, normally I can use the interface to get the Service (at least I could in XF).

I've tried to configure the IService with container.RegisterPerRequest (as in the sample) but also I tried:

container.PerRequest<IService, MyService>();
contain.Singleton<IService, MyService>():

All these produce the same error.

Is this functioning as designed for Maui?

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions