Can't get Prism 8 with DryIoc RegisterServices and Platform-Specific support to work

Viewed 371

Trying to use Prism 8, ContainerLocator, IHttpClientFactory and Platform-Specific Service registration with DryIoc Extensions (not Magician) in a Xamarin Forms application

I have these nuget packages installed

Prism.DryIoc.Extensions
Prism.Forms

My main Xamarin Application inherits from PrismApplicationBase.

In platform code (eg Android) I have IPlatformInitializer implented by MainActivity and for platform-specific services I use:

LoadApplication(new App(this));

as documented here: https://prismlibrary.com/docs/dependency-injection/platform-specific-services.html

This line causes the IContainerExtension to be resolved in the shared code

protected override IContainerExtension CreateContainerExtension()

...but I can't find a way to successfully return a valid IContainerExtension implementation.

I've attempted:

https://prismlibrary.com/docs/dependency-injection/container-locator.html

var createContainerExtension = () => new DryIocContainerExtension();
ContainerLocator.SetContainerExtension(createContainerExtension);

But the code given here can't even compile - the DryIocContainerExtension class created is defined INTERNAL and isn't available to my application code.

If I use...

PrismContainerExtension.Init();

or

return ContainerLocator.Current;

...as worked previously (eg Prism 7.2) I get a runtime error as described here: https://githubmemory.com/repo/dansiegel/Prism.Container.Extensions/issues/180

ValueFactory attempted to access the Value property of this instance.

Please can someone advise what I'm doing wrong, or do I have to get my company to pay for Magician to resolve my issue?

0 Answers
Related