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>
Error screenshot
Steps to reproduce the issue:
I'm not sure if this can be easily reproduced.
-
Create 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?)
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.
2 Answer(s)
-
0
Hi,
It's hard to determine the exact problem right now but here is some extra suggestions to find the source of problem and we can help then:
-
Investigate Dependencies: The error indicates a problem with
Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance
. Ensure that all dependencies related to this library are properly included in your project and container. Sometimes, certain assemblies may not be copied during the publishing process. Verify the contents of thebin/Release/net9.0/publish/
folder. -
Check .NET Version: Ensure the container is using the correct version of the .NET runtime that matches your application's target framework. The
Dockerfile
usesmcr.microsoft.com/dotnet/aspnet:9.0
, so confirm this aligns with your application. -
Debug Assembly Loading: Since this issue occurs only in the containerized environment, it could be related to assembly loading. You might need to explicitly include certain assemblies in the
Dockerfile
or publishing settings. -
Test with Minimal Setup: Try running the application in a simpler containerized environment, like Docker alone, instead of Kubernetes. This can help isolate Kubernetes-specific issues.
-
Update ABP Framework: If you're not using the latest version of ABP Framework, consider updating it to rule out potential framework bugs.
-
WebAssembly Module Loading: The error happens when loading the WebAssembly UI module. Look into how the module is loaded and initialized, especially in a containerized environment. Ensure any required configuration files for the WebAssembly module are accessible within the container.
-
Logs and Diagnostics: Examine the application and container logs closely. While you mentioned the pod logs are clear, additional diagnostic tools like
dotnet-dump
ordotnet-trace
could provide insights into what happens at the point of failure.
These steps aim to help pinpoint the source of the issue and resolve the containerized deployment problem. Further information may help us to undertsand and solve the problem
-
-
0
hi @blepo
Can you share your test Blazor project?
I will try to reproduce it in the local environment and find out the reason.
You can share it with liming.ma@volosoft.com
Thanks.