Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building -f net9.0-android -c Release fails due to missing package System.Formats.Nrbf #27057

Open
StepKie opened this issue Jan 10, 2025 · 3 comments
Labels
t/bug Something isn't working

Comments

@StepKie
Copy link

StepKie commented Jan 10, 2025

Description

Our app built fine from CLI with

dotnet build -f net8.0-android -c Release

After upgrading to .NET9, and following the guidelines at https://learn.microsoft.com/en-us/dotnet/maui/whats-new/dotnet-9?view=net-maui-9.0,

the CLI build

dotnet build -f net9.0-android -c Release

fails with

Could not load signature of System.Windows.Forms.Nrbf.SerializationRecordExtensions+TryGetDelegate:BeginInvoke due
to: Could not load file or assembly 'System.Formats.Nrbf, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13
ffcd2ddd51' or one of its dependencies.

After dotnet add package System.Formats.Nrbf, the build again succeeds.

This seems related to https://devblogs.microsoft.com/dotnet/binaryformatter-removed-from-dotnet-9/ , but is not documented anywhere in the upgrade guide

Do I now have to manually add System.Formats.Nrbf to my MAUI project file?

Version with bug

9.0.22 SR2.2

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

Latest .NET8 release

Affected platforms

Android, I was not able test on other platforms

Did you find any workaround?

Install System.Formats.Nrbf manually.

Relevant log output

@StepKie StepKie added the t/bug Something isn't working label Jan 10, 2025
@mattleibow
Copy link
Member

Are you using the binary formatter in your project?

@StepKie
Copy link
Author

StepKie commented Jan 10, 2025

The removal was documented

I know, I said as much in my initial post (I just noticed that it was not mentioned in the upgrade guide in particular)

Are you using the binary formatter in your project?

no.

And that is the weird thing

  • It is not referenced anywhere in source code, or in transitively used nuget packages.
  • It compiles in .NET8
  • It just breaks in .NET9

Maybe some additional information:

The CLI error message /call stack:

Precompiling failed for \obj\Release\net9.0-android\android-arm64\linked\System.Private.Windows.Core.dll with exit code -1073741819.
Mono Ahead of Time compiler - compiling assembly \obj\Release\net9.0-android\android-arm64\linked\System.Private.Windows.Core.dll
AOTID 5682CF11-7D3A-E046-8F33-14DD1C85CB2B
Using profile data file '.nuget\packages\microsoft.maui.controls.build.tasks\9.0.22\buildTransitive\netstandard2.0\maui.aotprofile'
Using profile data file '.nuget\packages\microsoft.maui.controls.build.tasks\9.0.22\buildTransitive\netstandard2.0\maui-blazor.aotprofile'
Added 0 methods from profile.
Added 0 methods from profile.
Could not load signature of System.Windows.Forms.Nrbf.SerializationRecordExtensions+TryGetDelegate:BeginInvoke due to: Could not load file or assembly 'System.Formats.Nrbf, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies.

and then the same for \android-x64\ instead of \android-arm64\

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants