Hi, We have a Layered Modular Monolith app with Blazor WebApp UI. We also have added a custom module to this app. This module uses Blazor WebAssembly.
The solution has been generated using ABP Studio.
I've encountered a problem that only happens when the app is published to a container. We run this container on our local Kubernetes cluster.
I've tried various approaches to fix this, but I'm out of ideas.
The issue only happens in the containerized version. The app runs without issues in both Debug and Release modes from Visual Studio.
Error This is the error, as seen in the browser console (both Firefox and Edge):
ManagedError: AggregateException_ctor_DefaultMessage (Method not found: object Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(System.IServiceProvider,System.Type,object[]))
at an (dotnet.runtime.qrl1fuqt3c.js:3:26894)
at Kt.resolve_or_reject (dotnet.runtime.qrl1fuqt3c.js:3:26449)
at dotnet.runtime.qrl1fuqt3c.js:3:172526
at dotnet.runtime.qrl1fuqt3c.js:3:172590
at fr (dotnet.runtime.qrl1fuqt3c.js:3:35046)
at Fc (dotnet.runtime.qrl1fuqt3c.js:3:172173)
at 00b598be:0x1f0b8
at 00b598be:0x1c7c6
at 00b598be:0xea13
at 00b598be:0x1eb9c
callEntryPoint @ blazor.web.js:1
await in callEntryPoint
Hr @ blazor.web.js:1
await in Hr
Fr @ blazor.web.js:1
startWebAssemblyIfNotStarted @ blazor.web.js:1
resolveRendererIdForDescriptor @ blazor.web.js:1
determinePendingOperation @ blazor.web.js:1
refreshRootComponents @ blazor.web.js:1
(anonymous) @ blazor.web.js:1
setTimeout
rootComponentsMayRequireRefresh @ blazor.web.js:1
startLoadingWebAssemblyIfNotStarted @ blazor.web.js:1
The error is linked to the WebAssembly part of the frontend, I think. The logs in the pod are clear and do not indicate any issues.
Upon the first loading of the app, everything seems fine. However, I guess this is the server-side first render, and only of the app UI; the module comes later, as it is strictly WebAssembly.
How it happens On my local machine, the app's first loading looks like this:
Initial blank screen, loading the app
I see the first render of the home page, unresponsive.
After a moment, the app becomes responsive but not fully loaded. If I enter any of the menus, I will see the "Authorizing" message.
The module WebAssembly UI is loaded, the module menus appear on the navigation menu, and the app starts to work fully.
In the containerized version, upon the first load, the process ends at step 4. Only after I refresh, it tries to move to step 5. However, it never reaches it, and this is where the error happens.
Dockerfile
FROM mcr.microsoft.com/dotnet/aspnet:9.0
ENV ASPNETCORE_CULTURE=pl-PL \
ASPNETCORE_UI_CULTURE=pl-PL \
TZ=Europe/Warsaw \
LANG=pl_PL.UTF-8 \
LANGUAGE=pl_PL.UTF-8 \
LC_ALL=pl_PL.UTF-8
# Install required locales
RUN apt-get update \~~~~
&& apt-get install -y locales \
&& sed -i -e 's/# pl_PL.UTF-8 UTF-8/pl_PL.UTF-8 UTF-8/' /etc/locale.gen \
&& dpkg-reconfigure --frontend=noninteractive locales \
&& update-locale LANG=pl_PL.UTF-8
COPY bin/Release/net9.0/publish/ app/
RUN mkdir -p /app/certs
WORKDIR /app
ENV ASPNETCORE_URLS=http://+:80
ENTRYPOINT ["dotnet", "AppName.Blazor.dll"]
Publish FolderProfile
<?xml version="1.0" encoding="utf-8"?>
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
<Project>
<PropertyGroup>
<DeleteExistingFiles>true</DeleteExistingFiles>
<ExcludeApp_Data>false</ExcludeApp_Data>
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>bin\Release\net9.0\publish\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<_TargetId>Folder</_TargetId>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>net9.0</TargetFramework>
<ProjectGuid>[GUID]</ProjectGuid>
<SelfContained>false</SelfContained>
</PropertyGroup>
</Project>
Steps to reproduce the issue: I'm not sure if this can be easily reproduced.
Steps to reproduce the issue:
I'm not sure if this can be easily reproduced.
Create a Blazor WebApp project.
Add a DDD, layered module with Blazor WebAssembly as UI.
Containerize the app.
Run it (I guess it does not matter if it is on Kubernetes or just Docker?).
Desired outcome
App running in a container on Kubernetes.
I'm not sure what parts of our code are relevant to this issue, as I have no idea what may be causing it.
Thanks in advance.