question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fix: Icon and Emoji

See original GitHub issue

Hello very good, I am learning blazor with FluentUI. I am testing the different functionalities that you have, but there is one that is giving me a lot of problems to solve, which are: icons and emojis. The error I currently have is the following, This only appears in the console of the internet explorer (in this case I use Microsoft Edge) and no error appears in Visual Studio Professional:

Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
       Unhandled exception rendering component: The requested icon (FolderMail, Size16, Regular) is not available in the collection
System.ArgumentException: The requested icon (FolderMail, Size16, Regular) is not available in the collection
    at Microsoft.Fast.Components.FluentUI.FluentIcon.OnParametersSet() in /_/src/Microsoft.Fast.Components.FluentUI/Components/Icon/FluentIcon.cs:line 109
    at Microsoft.AspNetCore.Components.ComponentBase.CallOnParametersSetAsync()
    at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()

The steps I have followed are:

  1. I’m with a Blazor WebAssembly project.
  2. I have installed Microsoft.Fast.Components.FluentUI using the NuGet package manager that has Visual Studio Professional. The version in question is 2.4.1
  3. Then I modified the _import.razor file, leaving it as follows:
@using System.Net.Http
@using System.Net.Http.Json
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.AspNetCore.Components.WebAssembly.Http
@using Microsoft.JSInterop
@using WebPage.Client
@using WebPage.Client.Shared
@using Microsoft.Fast.Components.FluentUI
  1. Then I modified the .psproj (in my case it is PaginaWeb.Client.csproj ) with the following:
<PropertyGroup>
<PublishFluentIconAssets>true</PublishFluentIconAssets>
<FluentIconSizes>10,12,16,20,24,28,32,48</FluentIconSizes>
<FluentIconVariants>Filled,Regular</FluentIconVariants>
<PublishFluentEmojiAssets>true</PublishFluentEmojiAssets>
<FluentEmojiGroups>Activities,Animals_Nature,Flags,Food_Drink,Objects,People_Body,Smileys_Emotion,Symbols,Travel_Places</FluentEmojiGroups>
<FluentEmojiStyles>Color,Flat,HighContrast</FluentEmojiStyles>
</PropertyGroup>

With the following result:

<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

   <PropertyGroup>
     <TargetFramework>net7.0</TargetFramework>
     <Nullable>enable</Nullable>
     <ImplicitUsings>enable</ImplicitUsings>
   </PropertyGroup>

   <ItemGroup>
     <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.7" />
     <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.7" PrivateAssets="all" />
     <PackageReference Include="Microsoft.Fast.Components.FluentUI" Version="2.4.1" />
   </ItemGroup>

   <ItemGroup>
     <ProjectReference Include="..\Shared\WebPage.Shared.csproj" />
   </ItemGroup>

<PropertyGroup>
<PublishFluentIconAssets>true</PublishFluentIconAssets>
<FluentIconSizes>10,12,16,20,24,28,32,48</FluentIconSizes>
<FluentIconVariants>Filled,Regular</FluentIconVariants>
<PublishFluentEmojiAssets>true</PublishFluentEmojiAssets>
<FluentEmojiGroups>Activities,Animals_Nature,Flags,Food_Drink,Objects,People_Body,Smileys_Emotion,Symbols,Travel_Places</FluentEmojiGroups>
<FluentEmojiStyles>Color,Flat,HighContrast</FluentEmojiStyles>
</PropertyGroup>

</Project>
  1. Also, in the program.cs file I added the following code:
builder.Services.AddFluentUIComponents(options =>
{
     options.HostingModel = BlazorHostingModel.WebAssembly;
     options.IconConfiguration = ConfigurationGenerator.GetIconConfiguration();
     options.EmojiConfiguration = ConfigurationGenerator.GetEmojiConfiguration();
});

Leaving the program in this way:

using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Fast.Components.FluentUI;
using WebPage.Client;
using System.Reflection.Metadata;
using System.Runtime.Intrinsics.X86;

var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddFluentUIComponents();
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

await builder.Build().RunAsync();

builder.Services.AddFluentUIComponents(options =>
{
     options.HostingModel = BlazorHostingModel.WebAssembly;
     options.IconConfiguration = ConfigurationGenerator.GetIconConfiguration();
     options.EmojiConfiguration = ConfigurationGenerator.GetEmojiConfiguration();
});
  1. In the end, all the code that I make that has Icons and emojis fails in the way that I mentioned above, it only gives an error in the browser console. For example with this simple code:
<h4>With start</h4>
<FluentTextField @bind-Value=value1>
     <FluentIcon Name="@FluentIcons.FolderMail" Size="@IconSize.Size16" Variant="@IconVariant.Regular" Color="@Color.Accent"/>
</FluentTextField>


@code {
     string? value1, value2;
}

It gives an error specifically in the FluentIcon part since when removing it, it does not give an error in the console.

Can you help me please? There is not much information about this error and I don’t know what to do anymore.

Issue Analytics

  • State:closed
  • Created 2 months ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
mrpmorriscommented, Jul 21, 2023

I would also recommend using the new V3 RC1, there is no need for the extra project settings etc.

0reactions
LuisGTF-UMcommented, Aug 1, 2023

Thanks for the help received. In the end I had to upgrade to version 3.0.0-RC.1 using the NuGet package manager and install the emoji and icon packs that were in preview. I also installed the templates and am now working with them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To FIX Missing Emojis On Android! (2022) - YouTube
Bro when I use watsapp there showing missing emojis on my keyboard not on watsapp keyboard but when I started another app in...
Read more >
🛠️ Hammer and Wrench Emoji
A hammer and wrench, as kept in a toolbox, crossed in an X shape. Depicted with metal tools facing up, the hammer positioned...
Read more >
How do you change a list/folder icon to an emoji? : r/ticktick
On PC/Web. Right click on the list you want to add the emoji. Click Edit. Click the 3 bars on the left side...
Read more >
Fix emoji search in Windows 10 - Thom's HeadSpace
This is a quick post to explain how you can get search working from the emoji keyboard in Windows 10 or Windows 11....
Read more >
Use emoji and symbols on Mac
On your Mac, enter emoji, symbols, and other special characters using the Character ... To change Keyboard settings, choose Apple menu > System...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found