I would like to use IHttpClientFactory
in a WPF application built using the Prism library. I have added two packages, Prism.Unity and Prism.Unity.Extensions and i attempt to register the IHttpClientFactory
with the following code:
containerRegistry.RegisterServices(s => s.AddHttpClient("DefaultClient")
.AddPolicyHandler(GetRetryPolicy()));
However, I get the following error:
I have also added the following override:
protected override IContainerExtension CreateContainerExtension() => PrismContainerExtension.Current;
Prism 8 introduces registration methods for scoped services. The
IContainerProvider
interface declares an additional methodCreateScope
and a memberCurrentScope
that were not present in earlier versions.The
PrismContainerExtension
classes from Prism.Unity.Extensions in version 7.2.0.1054 and earlier do not implement this method. Consequently, you get an exception using it with Prism 8.Since the types are incompatible, you either have to revert to Prism 7.2.0.1054 or you have to wait for a new version of Prism.Unity.Extensions that supports the new scoped services in Prism 8. There are already changes made in the repository, but a preview version is currently only available to sponsors.