Android framework version
net11.0-android (Preview)
Affected platform version
.NET 11
Description
There is a timing issue for startup on NativeAOT:
- If you set an env var specific to the runtime, like
$DOTNET_STARTUP_HOOKS - NativeAOT runs startup hooks before any of our managed code runs
- Then our startup code is called, and we populate env vars
- But then its too late,
$DOTNET_STARTUP_HOOKS was already read
Hot Reload doesn't work on NativeAOT, but this could be problematic for other runtime-specific env vars.
To fix, I think we'd have to call Java -> native code, to set env vars earlier at startup.
Steps to Reproduce
Run tests\Mono.Android-Tests\Mono.Android-Tests\Mono.Android.NET-Tests.csproj.
But remove the check for NativeAOT:
<!-- Set STARTUP_HOOKS via RuntimeHostConfigurationOption for MonoVM and NativeAOT (read via AppContext.GetData) -->
<RuntimeHostConfigurationOptionInclude="STARTUP_HOOKS"Value="StartupHook"Condition=" '$(UseMonoRuntime)' == 'true' or '$(PublishAot)' == 'true' " />
To rely on $DOTNET_STARTUP_HOOKS=StartupHook instead.
Did you find any workaround?
Set STARTUP_HOOKS app context switch.
Relevant log output
Android framework version
net11.0-android (Preview)
Affected platform version
.NET 11
Description
There is a timing issue for startup on NativeAOT:
$DOTNET_STARTUP_HOOKS$DOTNET_STARTUP_HOOKSwas already readHot Reload doesn't work on NativeAOT, but this could be problematic for other runtime-specific env vars.
To fix, I think we'd have to call Java -> native code, to set env vars earlier at startup.
Steps to Reproduce
Run
tests\Mono.Android-Tests\Mono.Android-Tests\Mono.Android.NET-Tests.csproj.But remove the check for NativeAOT:
To rely on
$DOTNET_STARTUP_HOOKS=StartupHookinstead.Did you find any workaround?
Set
STARTUP_HOOKSapp context switch.Relevant log output