首页 > 解决方案 > 将 blazor 应用程序托管到 Windows 服务器时,如何解决以下问题?

问题描述

当我将我的 blazor 应用程序上传到 Windows 服务器时,出现以下问题。我尝试了不同的解决方案,但未能成功。如果任何机构遇到同样的问题并且可以帮助解决这个问题,那将会很有帮助。

它在本地运行良好,但是当我发布 blazor.server 应用程序然后上传或托管到服务器时,就会出现此问题。它在 asp.net 核心 3.1 中。

致命一击:Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer [100] 未处理的异常渲染组件:未找到类型 Microsoft.AspNetCore.Components.Authorization.CascadingAuthenticationState System.MissingMethodException 的默认构造函数:未找到类型 Microsoft.AspNetCore 的默认构造函数。 Components.Authorization.CascadingAuthenticationState at System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic, System.Boolean wrapExceptions) <0x1c4b380 + 0x000b0> in :0 at System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly, System.Boolean wrapExceptions, System.Boolean skipCheckThis, System.Boolean fillCache) <0x1c4b1b8 + 0x0001c> 在 System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Boolean wrapExceptions, System.Threading.StackCrawlMark& stackMark) <0x1c4b050 + 0x0002e> in :0 at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic, System.Boolean wrapExceptions) <0x1ca3880 + 0x00062> in :0 at System .Activator.CreateInstance(System.Type 类型,System.Boolean nonPublic)<0x1ca3840 + 0x0000a> 在 System.Activator.CreateInstance(System.Type 类型)<0x1ca3780 + 0x00006> 中:0 在 Microsoft.AspNetCore.Components。 ComponentFactory.InstantiateComponent (System.IServiceProvider serviceProvider, System.Type componentType) <0x1ca3660 + 0x00006> in :0 at Microsoft.AspNetCore.Components.RenderTree.Renderer.InstantiateComponent (System.Type componentType) <0x1ca26d8 + 0x00014> in :0 at Microsoft .AspNetCore.Components.RenderTree.Renderer。InstantiateChildComponentOnFrame (Microsoft.AspNetCore.Components.RenderTree.RenderTreeFrame& 框架, System.Int32 parentComponentId) <0x1f5c1e0 + 0x0005c> 在 Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewComponentFrame (Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder+DiffContext& diffContext, System.Int32 frameIndex) <0x1f5c070 + 0x0004c> 在 Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewSubtree (Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder+DiffContext& diffContext, System.Int32 frameIndex) <0x1f5bdf0 + 0x0007a 处:0 > 在:0 在 Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder+DiffContext& diffContext,系统。Int32 newFrameIndex) <0x1f5bae8 + 0x000b4> in :0 at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange (Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder+DiffContext& diffContext, System.Int32 oldStartIndex, System.Int32 oldEndIndexExcl, System.Int32 newStartIndex, System.Int32 newEndIndexExcl) <0x1f5af18 + 0x0048c> 在 Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff (Microsoft.AspNetCore.Components.RenderTree.Renderer 渲染器, Microsoft.AspNetCore.Components.Rendering.RenderBatchBuilder batchBuilder, System.Int32 componentId,Microsoft.AspNetCore.Components.RenderTree.ArrayRangeComponents.RenderTree.RenderTreeDiffBuilder+DiffContext& diffContext, System.Int32 oldStartIndex, System.Int32 oldEndIndexExcl, System.Int32 newStartIndex, System.Int32 newEndIndexExcl) <0x1f5af18 + 0x0048c> in :0 at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff ( Microsoft.AspNetCore.Components.RenderTree.Renderer 渲染器,Microsoft.AspNetCore.Components.Rendering.RenderBatchBuilder batchBuilder,System.Int32 componentId,Microsoft.AspNetCore.Components.RenderTree.ArrayRangeComponents.RenderTree.RenderTreeDiffBuilder+DiffContext& diffContext, System.Int32 oldStartIndex, System.Int32 oldEndIndexExcl, System.Int32 newStartIndex, System.Int32 newEndIndexExcl) <0x1f5af18 + 0x0048c> in :0 at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff ( Microsoft.AspNetCore.Components.RenderTree.Renderer 渲染器,Microsoft.AspNetCore.Components.Rendering.RenderBatchBuilder batchBuilder,System.Int32 componentId,Microsoft.AspNetCore.Components.RenderTree.ArrayRangeRenderTree.Renderer 渲染器,Microsoft.AspNetCore.Components.Rendering.RenderBatchBuilder batchBuilder,System.Int32 componentId,Microsoft.AspNetCore.Components.RenderTree.ArrayRangeRenderTree.Renderer 渲染器,Microsoft.AspNetCore.Components.Rendering.RenderBatchBuilder batchBuilder,System.Int32 componentId,Microsoft.AspNetCore.Components.RenderTree.ArrayRange1[T] oldTree, Microsoft.AspNetCore.Components.RenderTree.ArrayRange1[T] newTree) <0x1f59ff0 + 0x0008c> 在 :0 在 Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch (Microsoft.AspNetCore.Components.Rendering.RenderBatchBuilder batchBuilder, Microsoft.AspNetCore.Components.RenderFragment renderFragment) <0x1f53dd0 + 0x00100> 在:0 在 Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderInExistingBatch (Microsoft.AspNetCore.Components.Rendering.RenderQueueEntry renderQueueEntry) <0x1f518e0 + 0x0004c> 在:0 在 Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue ( ) <0x1f51020 + 0x00092> 在 :0

标签: c#.netasp.net-coreblazor

解决方案


对此不确定,但在我看来,禁用链接器将解决问题......这是一个临时解决方案......对于正确的解决方案,请咨询 Blazor 团队

<PropertyGroup>
    <BlazorWebAssemblyEnableLinking>false</BlazorWebAssemblyEnableLinking>
</PropertyGroup>

推荐阅读