如何修复MAUI中的编译时错误 – 无法编译本机程序集文件

huangapple go评论73阅读模式
英文:

How can I fix compile time error in MAUI - Could not compile native assembly file

问题

当我在Visual Studio 2022中创建新的MAUIXamarin.Forms项目时,在构建项目时出现错误。我尝试过各种Visual Studio版本(卸载/重新安装),包括最新的VS预览版2。当我构建项目时,只在Android项目中出现错误。

重新生成中...
已还原 C:\Users\user.name\source\repos\MauiApp1\MauiApp1.csproj(用时 889 毫秒)。
1>------ 重新生成全部开始: 项目: MauiApp1,配置: Debug Any CPU ------
1>MauiApp1 -> C:\Users\user.name\source\repos\MauiApp1\bin\Debug\net7.0-ios\iossimulator-x64\MauiApp1.dll
1>MauiApp1 -> C:\Users\user.name\source\repos\MauiApp1\bin\Debug\net7.0-maccatalyst\maccatalyst-x64\MauiApp1.dll
1>MauiApp1 -> C:\Users\user.name\source\repos\MauiApp1\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\MauiApp1.dll
1>MauiApp1 -> C:\Users\user.name\source\repos\MauiApp1\bin\Debug\net7.0-android\MauiApp1.dll
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows.0.46\tools\Xamarin.Android.Common.targets(1987,3): error XA3006: 无法编译本机程序集文件: typemaps.arm64-v8a.ll
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows.0.46\tools\Xamarin.Android.Common.targets(1987,3): error XA3006: 
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows.0.46\tools\Xamarin.Android.Common.targets(1987,3): error XA3006: 
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows.0.46\tools\Xamarin.Android.Common.targets(1987,3): error XA3006:
1>项目构建完成“MauiApp1.csproj” -- 失败。
========== 重新生成全部: 0 个成功,1 个失败,0 个跳过 ==========
========== 重新生成开始于下午4:16并花费了01:10.747分钟 ==========

MAUI项目中,当我将目标设置为.Net 6.0没有错误。当我使用.Net 7.0.Net 8.0时,我遇到了这个错误。

以下是错误的截图。有时我会得到一个、两个或三个错误。它们是随机的,但都与arm架构有关。也有可能给出的错误与实际错误无关。这已经在GitHub上的问题上讨论过。

如何修复MAUI中的编译时错误 – 无法编译本机程序集文件

我尝试过删除obj和bin目录、清理项目、重新加载和卸载以及以管理员身份打开VS,仍然遇到相同的错误。

我甚至在github.com/dotnet/mauilearn.microsoft.comdevelopercommunity.visualstudio上报告了这个问题,但没有解决方案。我该如何修复这个问题?

英文:

When I create new MAUI or Xamarin.Forms project in Visual Studio 2022, I get errors at the time of building project. I have tried various Visual Studio version (uninstall/reinstall) including latest VS Preview 2. When I build project, I get errors only in Android project.

Rebuild started...
Restored C:\Users\user.name\source\repos\MauiApp1\MauiApp1.csproj (in 889 ms).
1>------ Rebuild All started: Project: MauiApp1, Configuration: Debug Any CPU ------
1>MauiApp1 -> C:\Users\user.name\source\repos\MauiApp1\bin\Debug\net7.0-ios\iossimulator-x64\MauiApp1.dll
1>MauiApp1 -> C:\Users\user.name\source\repos\MauiApp1\bin\Debug\net7.0-maccatalyst\maccatalyst-x64\MauiApp1.dll
1>MauiApp1 -> C:\Users\user.name\source\repos\MauiApp1\bin\Debug\net7.0-windows10.0.19041.0\win10-x64\MauiApp1.dll
1>MauiApp1 -> C:\Users\user.name\source\repos\MauiApp1\bin\Debug\net7.0-android\MauiApp1.dll
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows.0.46\tools\Xamarin.Android.Common.targets(1987,3): error XA3006: Could not compile native assembly file: typemaps.arm64-v8a.ll
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows.0.46\tools\Xamarin.Android.Common.targets(1987,3): error XA3006: 
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows.0.46\tools\Xamarin.Android.Common.targets(1987,3): error XA3006: 
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows.0.46\tools\Xamarin.Android.Common.targets(1987,3): error XA3006:
1>Done building project "MauiApp1.csproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
========== Rebuild started at 4:16 PM and took 01:10.747 minutes ==========

In MAUI project when I target .Net 6.0 no errors. When I use .Net 7.0 or .Net 8.0 I am facing this error.

Errors screenshot below. Sometimes I get one, two or three error. Those are random but all are related to arm architecture. There might be chances that given errors has nothing to do with actual error. This has been discussed on issue posted on GitHub

如何修复MAUI中的编译时错误 – 无法编译本机程序集文件

I have tried deleting obj and bin, cleaning project, reload and unload and opening VS as Admin, still facing same errors.

Even I have reported this issue at github.com/dotnet/maui, at learn.microsoft.com and at developercommunity.visualstudio No solution. How can I fix that ?

答案1

得分: 0

此问题已得到解决。有关详细信息,请访问以下网址。这应该与 Xamarin 和 MAUI 的下一个发布一起发布。

https://github.com/dotnet/maui/issues/14531

英文:

This issue is got fixed. For more visit the below URL. This should be release along with next release of Xamarin and MAUI

https://github.com/dotnet/maui/issues/14531

huangapple
  • 本文由 发表于 2023年6月26日 16:39:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76554967.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定