-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kiota C# Client crashes on Blazor WASM #481
Comments
I found that Using a custom HttpClient is a workaround. i.e:
|
Hi @brad-technologik Does it make any difference if you use the kiota factory method instead to get the http client? |
Yes, using I pushed my minimal repro. You can comment/uncomment this line to toggle the crash. |
Thank you for the additional information. It's strange that blazor would be able to "translate" the call to new up an http client in the application code but not in a library.
|
Can you re-open this bug? It's not resolved. I provided sufficient reproduction steps and I don't have the time to perform debugging to narrow down the root cause but I think it should remain in a backlog somewhere. |
@brad-technologik can you at least take the time to run the last test I've suggested please? |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. |
What are you generating using Kiota, clients or plugins?
API Client/SDK
In what context or format are you using Kiota?
Nuget tool
Client library/SDK language
Csharp
Describe the bug
When I try and import my Kiota C# in a Blazor WASM Project, the page gets an error whenever the Kiota client is injected into a page:
Expected behavior
Kiota C# client should work in Blazor. The error is kind of vague, but it may be related to multi threading which isn't supported in Blazor.
Given how Kiota and Blazor are both Microsoft products, I'd expect them work together.
How to reproduce
dotnet new blazor -ai -int WebAssembly -n KiotaBlazorBug cd KiotaBlazorBug/KiotaBlazorBug.Client dotnet add package Microsoft.Kiota.Bundle kiota generate --language=CSharp -d https://petstore3.swagger.io/api/v3/openapi.json -o ./Client -c PetStoreClient -n KiotaBlazorBug.Client
Add the following code to
Program.cs
(In bothKiotaBlazorBug/KiotaBlazorBug/Program.cs
andKiotaBlazorBug/KiotaBlazorBug.Client
)Add the following line to
Counter.razor
Run the project
Visit http://localhost:5003/counter in your Browser and observe the error and JS console.
Open API description file
Any one. https://petstore3.swagger.io/api/v3/openapi.json is an example.
Kiota Version
1.20.0+81bdb1bf13383a749f794d47926d09733d2d7be1
Latest Kiota version known to work for scenario above?(Not required)
No response
Known Workarounds
No response
Configuration
Debug output
Click to expand log
``` blazor.web.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: Operation is not supported on this platform. System.PlatformNotSupportedException: Operation is not supported on this platform. at System.Net.Http.SocketsHttpHandler.set_Proxy(IWebProxy value) at Microsoft.Kiota.Http.HttpClientLibrary.KiotaClientFactory.GetDefaultHttpMessageHandler(IWebProxy proxy) at Microsoft.Kiota.Http.HttpClientLibrary.KiotaClientFactory.Create(HttpMessageHandler finalHandler, IRequestOption[] optionsForHandlers) at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter..ctor(IAuthenticationProvider authenticationProvider, IParseNodeFactory parseNodeFactory, ISerializationWriterFactory serializationWriterFactory, HttpClient httpClient, ObservabilityOptions observabilityOptions) at Program.<>c.<$>b__0_0(IServiceProvider e) in /Users/brad/tmp/kiota-bug/KiotaBlazorBug/KiotaBlazorBug.Client/Program.cs:line 12 at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=9.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSiteMain(ServiceCallSite callSite, RuntimeResolverContext argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=9.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSite(ServiceCallSite callSite, RuntimeResolverContext argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope) at Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeServiceProviderEngine.<>c__DisplayClass4_0.b__0(ServiceProviderEngineScope scope) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope) at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType) at Microsoft.AspNetCore.Components.ComponentFactory.<>c__DisplayClass9_0.g__Initialize|1(IServiceProvider serviceProvider, IComponent component) at Microsoft.AspNetCore.Components.ComponentFactory.InstantiateComponent(IServiceProvider serviceProvider, Type componentType, IComponentRenderMode callerSpecifiedRenderMode, Nullable`1 parentComponentId) at Microsoft.AspNetCore.Components.RenderTree.Renderer.InstantiateChildComponentOnFrame(RenderTreeFrame[] frames, Int32 frameIndex, Int32 parentComponentId) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewComponentFrame(DiffContext& diffContext, Int32 frameIndex) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewSubtree(DiffContext& diffContext, Int32 frameIndex) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& diffContext, Int32 newFrameIndex) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer renderer, RenderBatchBuilder batchBuilder, Int32 componentId, ArrayRange`1 oldTree, ArrayRange`1 newTree) at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException) at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderInExistingBatch(RenderQueueEntry renderQueueEntry) at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()The text was updated successfully, but these errors were encountered: