4

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?

Dave R
  • 1,626
  • 19
  • 28
  • Hi @Dave R - a LONG time since you posted this so I know I'm asking a lot... but can you remember if you got this issue resolved? Similarly I had it working with Prism 7.2 but after moving to 8 I get same error! – Tomás Apr 18 '23 at 13:26

0 Answers0