Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't show Fluent UI Blazor dialog on published Blazor webasm app. #1057

Closed
cmsw97 opened this issue Dec 1, 2023 · 2 comments
Closed

Can't show Fluent UI Blazor dialog on published Blazor webasm app. #1057

cmsw97 opened this issue Dec 1, 2023 · 2 comments

Comments

@cmsw97
Copy link

cmsw97 commented Dec 1, 2023

馃悰 Bug Report

Not sure if a bug or if I'm doing something wrong, but when I try to show a FluentUI Blazor dialog in a published Blazor app, I get the error "Unhandled exception rendering component: Arg_NoDefCTor, Microsoft.FluentUI.AspNetCore.Components.MessageBox". It works fine in debug mode tough.

馃捇 Repro or Code Sample

  1. Create a new app using "Fluent Blazor WebAssembly Standalone App" template in VS, with the following settings:
    image

  2. Add <FluentDialogProvider /> at the end of MainLayout.razor.

  3. At the end of Home.razor, add the following:

@code {
	protected override void OnAfterRender(bool firstRender)
	{
		DialogService.ShowWarning("Danger!");
	}
}
  1. Run the program in debug mode inside VS just to check that the dialog shows as expected.

  2. Publish the app with dotnet publish -c Release.

  3. Run the published app and the error occurs.

馃 Expected Behavior

To be able to see the dialog warning in published app, just as in debug app.

馃槸 Current Behavior

An unhandled exception occurs. The DevTools console shows the following

blazor.webassembly.js:1  crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: Arg_NoDefCTor, Microsoft.FluentUI.AspNetCore.Components.MessageBox
System.MissingMethodException: Arg_NoDefCTor, Microsoft.FluentUI.AspNetCore.Components.MessageBox
   at System.RuntimeType.CreateInstanceMono(Boolean , Boolean )
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean , Boolean )
   at System.Activator.CreateInstance(Type , Boolean , Boolean )
   at System.Activator.CreateInstance(Type , Boolean )
   at System.Activator.CreateInstance(Type )
   at Microsoft.AspNetCore.Components.DefaultComponentActivator.CreateInstance(Type )
   at Microsoft.AspNetCore.Components.ComponentFactory.InstantiateComponent(IServiceProvider , Type , IComponentRenderMode , Nullable`1 )
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.InstantiateChildComponentOnFrame(RenderTreeFrame[] , Int32 , Int32 )
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewComponentFrame(DiffContext& , Int32 )
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewSubtree(DiffContext& , Int32 )
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& , Int32 )
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& , Int32 , Int32 , Int32 , Int32 )
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer , RenderBatchBuilder , Int32 , ArrayRange`1 , ArrayRange`1 )
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder , RenderFragment , Exception& )
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderInExistingBatch(RenderQueueEntry )
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()
Ft @ blazor.webassembly.js:1
(anonymous) @ dotnet.runtime.8.0.0.14kkjimq5k.js:3
Ul @ dotnet.runtime.8.0.0.14kkjimq5k.js:3
[...]
$mono_wasm_invoke_method_bound @ 00a66bc6:0x1dd4a3
Module._mono_wasm_invoke_method_bound @ dotnet.native.8.0.0.kqkgaror27.js:8
kr @ dotnet.runtime.8.0.0.14kkjimq5k.js:3
l.javaScriptExports.complete_task @ dotnet.runtime.8.0.0.14kkjimq5k.js:3
(anonymous) @ dotnet.runtime.8.0.0.14kkjimq5k.js:3
Promise.then (async)
mo @ dotnet.runtime.8.0.0.14kkjimq5k.js:3
(anonymous) @ dotnet.runtime.8.0.0.14kkjimq5k.js:3
(anonymous) @ dotnet.runtime.8.0.0.14kkjimq5k.js:3
Ul @ dotnet.runtime.8.0.0.14kkjimq5k.js:3
[...]
$mono_wasm_invoke_method_bound @ 00a66bc6:0x1dd4a3
Module._mono_wasm_invoke_method_bound @ dotnet.native.8.0.0.kqkgaror27.js:8
kr @ dotnet.runtime.8.0.0.14kkjimq5k.js:3
l.javaScriptExports.call_entry_point @ dotnet.runtime.8.0.0.14kkjimq5k.js:3
Nc @ dotnet.runtime.8.0.0.14kkjimq5k.js:3
callEntryPoint @ blazor.webassembly.js:1
hn @ blazor.webassembly.js:1
await in hn (async)
mn @ blazor.webassembly.js:1
Cn @ blazor.webassembly.js:1
(anonymous) @ blazor.webassembly.js:1
(anonymous) @ blazor.webassembly.js:1
blazor.webassembly.js:1  crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: Arg_NullReferenceException
System.NullReferenceException: Arg_NullReferenceException
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForFramesWithSameSequence(DiffContext& , Int32 , Int32 )
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& , Int32 , Int32 , Int32 , Int32 )
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer , RenderBatchBuilder , Int32 , ArrayRange`1 , ArrayRange`1 )
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder , RenderFragment , Exception& )
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderInExistingBatch(RenderQueueEntry )
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()

馃實 Your Environment

  • Visual Studio 2022 17.8.1
  • .NET 8.0.100
  • Microsoft.FluentUI.AspNetCore.Components 4.1.1
@vnbaaij
Copy link
Collaborator

vnbaaij commented Dec 2, 2023

This error is the reult of the trimmer being too enthusiastic.

@dvoituron set the TrimmerRootAssembly value in the project file to solve?

@dvoituron
Copy link
Collaborator

Yes, you can add this config in your csproj.

<ItemGroup> <TrimmerRootAssembly Include="Microsoft.FluentUI.AspNetCore.Components" /> </ItemGroup>

But I will add a fix to avoid to set this config for MessageBox component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants