Skip to content

Commit f6d7cef

Browse files
authored
kb(Common): Update Lazy Loading KB (#2804)
1 parent adfe056 commit f6d7cef

File tree

1 file changed

+21
-31
lines changed

1 file changed

+21
-31
lines changed

knowledge-base/common-lazy-load-assemblies-wasm.md

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@ res_type: kb
1818
<td>Product</td>
1919
<td>UI for Blazor</td>
2020
</tr>
21-
<tr>
22-
<td>Version</td>
23-
<td>2.19.0 and above</td>
24-
</tr>
25-
<tr>
26-
<td>.NET version</td>
27-
<td>5 and above</td>
28-
</tr>
2921
</tbody>
3022
</table>
3123

@@ -42,53 +34,51 @@ All general guidance from the [Microsoft documentation](https://learn.microsoft.
4234
````XML.skip-repl
4335
<ItemGroup>
4436
<!-- Components and data binding -->
45-
<BlazorWebAssemblyLazyLoad Include="Telerik.Blazor.dll" />
46-
<BlazorWebAssemblyLazyLoad Include="Telerik.DataSource.dll" />
47-
<BlazorWebAssemblyLazyLoad Include="System.Data.Common.dll" />
48-
<BlazorWebAssemblyLazyLoad Include="System.Linq.Queryable.dll" />
37+
<BlazorWebAssemblyLazyLoad Include="Telerik.Blazor.wasm" />
38+
<BlazorWebAssemblyLazyLoad Include="Telerik.DataSource.wasm" />
39+
<BlazorWebAssemblyLazyLoad Include="System.Data.Common.wasm" />
40+
<BlazorWebAssemblyLazyLoad Include="System.Linq.Queryable.wasm" />
4941
<!-- Icons -->
50-
<BlazorWebAssemblyLazyLoad Include="Telerik.SvgIcons.dll" />
51-
<BlazorWebAssemblyLazyLoad Include="Telerik.FontIcons.dll" />
42+
<BlazorWebAssemblyLazyLoad Include="Telerik.SvgIcons.wasm" />
43+
<BlazorWebAssemblyLazyLoad Include="Telerik.FontIcons.wasm" />
5244
<!-- PivotGrid -->
53-
<BlazorWebAssemblyLazyLoad Include="Telerik.Pivot.Core.dll" />
54-
<BlazorWebAssemblyLazyLoad Include="Telerik.Pivot.DataProviders.Xmla.dll" />
45+
<BlazorWebAssemblyLazyLoad Include="Telerik.Pivot.Core.wasm" />
46+
<BlazorWebAssemblyLazyLoad Include="Telerik.Pivot.DataProviders.Xmla.wasm" />
5547
<!-- Scheduler -->
56-
<BlazorWebAssemblyLazyLoad Include="Telerik.Recurrence.dll" />
48+
<BlazorWebAssemblyLazyLoad Include="Telerik.Recurrence.wasm" />
5749
<!-- Excel export -->
58-
<BlazorWebAssemblyLazyLoad Include="Telerik.Documents.SpreadsheetStreaming.dll" />
59-
<BlazorWebAssemblyLazyLoad Include="Telerik.Zip.dll" />
50+
<BlazorWebAssemblyLazyLoad Include="Telerik.Documents.SpreadsheetStreaming.wasm" />
51+
<BlazorWebAssemblyLazyLoad Include="Telerik.Zip.wasm" />
52+
<!-- PDF export (only for version 8.0.0 and above) -->
53+
<BlazorWebAssemblyLazyLoad Include="Telerik.Documents.Spreadsheet.FormatProviders.Pdf.wasm" />
54+
<!-- Licensing (only for version 8.0.0 and above ) -->
55+
<BlazorWebAssemblyLazyLoad Include="Telerik.Licensing.Runtime.wasm" />
6056
</ItemGroup>
6157
````
6258

63-
* The assembly requirements depend on component usage, and not on feature usage. For example, both icon assemblies are always required, as our components render icons internally and must be aware of both types of icons. The assemblies, which are related to Excel export, are always required when using a Grid. `Telerik.Recurrence.dll` is required only when using the Scheduler.
59+
* The assembly requirements depend on component usage, and not on feature usage. For example, both icon assemblies are always required, as our components render icons internally and must be aware of both types of icons. The assemblies, which are related to Excel and PDF export, are always required when using a Grid. `Telerik.Recurrence.wasm` is required only when using the Scheduler.
6460
* Move the [`<TelerikRootComponent>`](slug:rootcomponent-overview) to a layout that is used only on pages that have the Telerik assemblies loaded.
6561
* Lazy loading of assemblies does not support dynamic service injection. As a result, remove the Telerik service registration (`builder.Services.AddTelerikBlazor();`) from `Program.cs`. If you are using [localization for the Telerik Blazor components](slug:globalization-localization), define the the localization service for the Telerik components with the `Localizer` parameter of the `<TelerikRootComponent>`. The key thing is to instantiate the localization service inline. It cannot be injected as a variable from the `@code { }` block, because that will throw runtime errors.
66-
67-
6862
````RAZOR.skip-repl
69-
7063
@using LazyLoadTelerikComponents.Shared.Services
7164
72-
7365
<TelerikRootComponent Localizer="@( new SampleResxLocalizer() )">
74-
7566
...
76-
7767
</TelerikRootComponent>
78-
7968
````
8069

8170
Overall, the lazy loading of assemblies at the correct time is a responsibility of the application. If an assembly is not loaded when required, the app will throw `System.IO.FileNotFoundException: Could not load file or assembly ...`. The loading code is in the `OnNavigateAsync` event handler of the `<Router>`. You can also define an optional loading screen inside the `<Router>` with a `<Navigating>` tag.
8271

83-
### .NET 8 and 9 Specifics
72+
### .NET Specifics
8473

85-
The following tips apply only to .NET 8 and 9 WebAssembly apps:
74+
The following tips apply to WebAssembly apps that use specific .NET versions:
8675

87-
* Use `.wasm` instead of `.dll` in the `.csproj` file and the `OnNavigateAsync` event handler.
88-
* [Register the lazy loader service manually](https://github.com/dotnet/aspnetcore/issues/51966) in the "server" `Program.cs`. Otherwise, you may get a `InvalidOperationException: Cannot provide a value for property 'AssemblyLoader' on type '...Routes'. There is no registered service of type 'Microsoft.AspNetCore.Components.WebAssembly.Services.LazyAssemblyLoader'.`
76+
* (.NET 7 and below) Use `.dll` instead of `.wasm` in the `.csproj` file and the `OnNavigateAsync` event handler.
77+
* (.NET 8 and above) [Register the lazy loader service manually](https://github.com/dotnet/aspnetcore/issues/51966) in the "server" `Program.cs`. Otherwise, you may get a `InvalidOperationException: Cannot provide a value for property 'AssemblyLoader' on type '...Routes'. There is no registered service of type 'Microsoft.AspNetCore.Components.WebAssembly.Services.LazyAssemblyLoader'.`
8978

9079
````C#.skip-repl
9180
using Microsoft.AspNetCore.Components.WebAssembly.Services;
81+
9282
builder.Services.AddScoped(typeof(LazyAssemblyLoader));
9383
````
9484

0 commit comments

Comments
 (0)