Kiota C# Client crashes on Blazor WASM #5807
Labels
Csharp
Pull requests that update .net code
status:waiting-for-author-feedback
Issue that we've responded but needs author feedback to close
type:bug
A broken experience
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: