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

Project build error Avalonia for android (XAPRAS7000 System.BadImageFormatException: Invalid number of sections declared in PE header) #15632

Open
ComradeSwarog opened this issue May 6, 2024 · 3 comments

Comments

@ComradeSwarog
Copy link

Describe the bug

Project build error Avalonia for android (XAPRAS7000 System.BadImageFormatException: Invalid number of sections declared in PE header)

To Reproduce

Create an Avalonia project using the wizard (Visual Studio 2022)

изображение

Install the latest packages

изображение

изображение

Call the project build
изображение

Result

Rebuild started at 21:23...
Restored W:\MyProjects\AvaloniaApplication1\AvaloniaApplication1\AvaloniaApplication1.csproj (in 52 ms).
Restored W:\MyProjects\AvaloniaApplication1\AvaloniaApplication1.Android\AvaloniaApplication1.Android.csproj (in 110 ms).
Restored W:\MyProjects\AvaloniaApplication1\MauiApp1\MauiApp1.csproj (in 381 ms).
1>------ Rebuild All started: Project: AvaloniaApplication1, Configuration: Debug Any CPU ------
1>AvaloniaApplication1 -> W:\MyProjects\AvaloniaApplication1\AvaloniaApplication1\bin\Debug\net7.0\AvaloniaApplication1.dll
2>------ Rebuild All started: Project: AvaloniaApplication1.Android, Configuration: Debug Any CPU ------
2>AvaloniaApplication1.Android -> W:\MyProjects\AvaloniaApplication1\AvaloniaApplication1.Android\bin\Debug\net7.0-android\AvaloniaApplication1.Android.dll
2>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.95\targets\Microsoft.Android.Sdk.AssemblyResolution.targets(107,5): error XAPRAS7000: System.BadImageFormatException: Invalid number of sections in declared in PE header.
2>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.95\targets\Microsoft.Android.Sdk.AssemblyResolution.targets(107,5): error XAPRAS7000:    at System.Reflection.PortableExecutable.PEHeaders.ReadSectionHeaders(PEBinaryReader& reader)
2>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.95\targets\Microsoft.Android.Sdk.AssemblyResolution.targets(107,5): error XAPRAS7000:    at System.Reflection.PortableExecutable.PEHeaders..ctor(Stream peStream, Int32 size, Boolean isLoadedImage)
2>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.95\targets\Microsoft.Android.Sdk.AssemblyResolution.targets(107,5): error XAPRAS7000:    at System.Reflection.PortableExecutable.PEReader.InitializePEHeaders()
2>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.95\targets\Microsoft.Android.Sdk.AssemblyResolution.targets(107,5): error XAPRAS7000:    at System.Reflection.PortableExecutable.PEReader.GetMetadataBlock()
2>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.95\targets\Microsoft.Android.Sdk.AssemblyResolution.targets(107,5): error XAPRAS7000:    at System.Reflection.Metadata.PEReaderExtensions.GetMetadataReader(PEReader peReader, MetadataReaderOptions options, MetadataStringDecoder utf8Decoder)
2>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.95\targets\Microsoft.Android.Sdk.AssemblyResolution.targets(107,5): error XAPRAS7000:    at Xamarin.Android.Tasks.ProcessAssemblies.DeduplicateAssemblies(List`1 output, Dictionary`2 symbols)
2>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.95\targets\Microsoft.Android.Sdk.AssemblyResolution.targets(107,5): error XAPRAS7000:    at Xamarin.Android.Tasks.ProcessAssemblies.RunTask()
2>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.95\targets\Microsoft.Android.Sdk.AssemblyResolution.targets(107,5): error XAPRAS7000:    at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 17
2>Done building project "AvaloniaApplication1.Android.csproj" -- FAILED.
========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========
========== Rebuild completed at 21:23 and took 06,527 seconds ==========

Similar problem on all versions
net7.0-android and net8.0-android

The build machine has all the necessary dependencies installed

  • All net platform from net6.0 - net8.0
  • Android SDK
  • MAUI

изображение
изображение

Expected behavior

Correct build of the project without errors

Avalonia version

11.0.10

OS

Android

Additional context

No response

@timunie
Copy link
Contributor

timunie commented May 7, 2024

can you try 11.1 beta?

@ComradeSwarog
Copy link
Author

can you try 11.1 beta?

Problem still exists =(
изображение

Maybe someone has encountered a similar error?

@timunie
Copy link
Contributor

timunie commented May 8, 2024

can you upload a very minimal sample for me to double-check? Is it a real world device or an emulator?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants