CodeBeamOrg / CodeBeam.GoogleApis.Blazor

A utility package for Google Apis in Blazor.
MIT License
9 stars 0 forks source link

I am Getting Cannot instantiate implementation type 'System.Net.Http.IHttpClientFactory' for service type 'System.Net.Http.IHttpClientFactory'. Error, #25

Open muzammil001 opened 1 year ago

muzammil001 commented 1 year ago

blazor.webassembly.js:1 System.AggregateException: One or more errors occurred. (Cannot instantiate implementation type 'System.Net.Http.IHttpClientFactory' for service type 'System.Net.Http.IHttpClientFactory'.) ---> System.ArgumentException: Cannot instantiate implementation type 'System.Net.Http.IHttpClientFactory' for service type 'System.Net.Http.IHttpClientFactory'. at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.Populate() at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory..ctor(ICollection1 descriptors) at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection1 serviceDescriptors, ServiceProviderOptions options) at Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(IServiceCollection services, ServiceProviderOptions options) at Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(IServiceCollection services, Boolean validateScopes) at Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyHostBuilder.<>c__DisplayClass5_0.<.ctor>b__0() at Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyHostBuilder.Build() at Program.

$(String[] args) in D:\Software Projects\Tutorials\GoogleApiBlazor\GoogleApiBlazor\Program.cs:line 13 --- End of inner exception stack trace ---

mckaragoz commented 1 year ago

Did you look at readme? You need to add builder.Services.AddCodeBeamGoogleApiServices(); in program.cs

muzammil001 commented 1 year ago

I did. It doesn't work.

muzammil001 commented 1 year ago

can you make a tutorial video of this? that how does this work?

muzammil001 commented 1 year ago

GoogleApiBlazor.zip

here's my code. please review it.

mckaragoz commented 1 year ago

GoogleApiBlazor.zip

here's my code. please review it.

Find a solution. Add builder.Services.AddHttpClient(); into you program.cs

muzammil001 commented 1 year ago

I've added this, but it showing me same error.

mckaragoz commented 1 year ago

I've added this, but it showing me same error.

Your project works on my computer. Remove the injection in Imports.razor and add into pages individually.

muzammil001 commented 1 year ago

It works thanks, but I got another error. Screenshot 2023-07-17 004708