xamarin-macios icon indicating copy to clipboard operation
xamarin-macios copied to clipboard

iOS application debugging crashes with "Failed to load AOT module" when Hot Reload is enabled in VS

Open evolutionerp opened this issue 2 years ago • 33 comments

Description

When referencing and using some packages like System.Text.Json (>= 6.0.0) in a Xamarin Forms / iOS project, the debugger crashes with:

error: Failed to load AOT module 'System.Memory' while running in aot-only mode: doesn't match assembly.

This feedback may be related.

The issue seems to be related to "Hot Reload" in VS2022 (both stable and preview versions)

The issue does not seem to be occur in Xamarin.iOS projects that don't reference Xamarin.Forms.

Steps to Reproduce

  1. Create a new Xamarin.Forms project, targeting iOS
  2. Add a reference to System.Text.Json (≥ 6.0.0) either on the iOS project itself, or the shared netstd project
  3. Use the referenced package somewhere, e.g. by calling:
System.Text.Json.JsonSerializer.Serialize(new { A = "String", B = 1 });
  1. Debug the application

The issue DOES NOT seem to be reproducible in Xamarin.iOS projects that don't reference Xamarin.Forms.

Expected Behavior

The application should run just fine, and the debugger should attach to it.

Actual Behavior

The debugger crashes with the following log in the "Debug" tab of Visual Studio:

2021-11-11 10:39:05.973 App1.iOS[547:28803] Xamarin.iOS: Successfully received USB connection from the IDE on port 10000, fd: 6
2021-11-11 10:39:05.974 App1.iOS[547:28803] Xamarin.iOS: Processing: 'start profiler: no'
2021-11-11 10:39:05.974 App1.iOS[547:28789] Xamarin.iOS: Profiler not loaded (disabled)

Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/Mono.Security.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/System.Core.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/System.Numerics.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/System.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/System.Net.Http.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/System.Drawing.Common.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/Xamarin.iOS.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/System.Xml.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/Xamarin.Forms.Platform.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/Xamarin.Forms.Core.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/System.ServiceModel.Internals.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/System.Runtime.Serialization.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/Xamarin.Forms.Platform.iOS.dll [External]
2021-11-11 10:39:06.782 App1.iOS[547:28789] Xamarin.iOS: Unable to locate assembly 'App1' (culture: '')

Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/Xamarin.Forms.Xaml.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.dll
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/System.Buffers.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/System.Runtime.CompilerServices.Unsafe.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/System.Memory.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/System.Text.Encodings.Web.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/System.Text.Json.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS.exe
Thread started:  xamarin/Xamarin.Forms#2
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/netstandard.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/System.Transactions.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/System.Data.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/System.Data.DataSetExtensions.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/System.IO.Compression.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/System.IO.Compression.FileSystem.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/System.ComponentModel.Composition.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/System.Web.Services.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/System.Xml.Linq.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/System.Numerics.Vectors.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/System.Threading.Tasks.Extensions.dll [External]
Loaded assembly: /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/Microsoft.Bcl.AsyncInterfaces.dll [External]
Resolved pending breakpoint for 'App1.iOS.Application.Main(System.String[])' to C:\Users\Dev\source\repos\App1\App1\App1.iOS\Main.cs:14 [0x00000].
Loaded assembly: data-0x114808000 [External]
Loaded assembly: data-0x11481c000 [External]
2021-11-11 10:39:07.467 App1.iOS[547:28789] error: Failed to load AOT module 'System.Memory' while running in aot-only mode: doesn't match assembly.

=================================================================

	Native Crash Reporting
=================================================================
Got a abrt while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

=================================================================
	Native stacktrace:
=================================================================

	0x1095a55b8 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : 

	0x10959c034 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : 
	0x1095a4b00 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : 
	0x1dacbad48 - /usr/lib/system/libsystem_platform.dylib : <redacted>
	0x1dacd5824 - /usr/lib/system/libsystem_pthread.dylib : pthread_kill
	0x18b0c70b4 - /usr/lib/system/libsystem_c.dylib : abort

	0x10972eba0 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : xamarin_find_protocol_wrapper_type
	0x10970ed4c - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : mono_pmip
	0x10970ed9c - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : mono_pmip
	0x109582934 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : 
	0x1095d7554 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : mono_pmip
	0x1095d8260 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : mono_pmip
	0x1095d4634 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : mono_pmip
	0x109610ba8 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.a
pp/App1.iOS : mono_pmip
	0x104deb378 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : 
	0x104deb46c - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : 
	0x104deb420 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : 
	0x104deb2a4 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : 
	0x104f58f14 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : 
	0x10555b5e0 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : 
	0x1095ac334 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : mono_pmip
	0x10965a560 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : mono_pmip
	0x1095b7e44 - /privat
e/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : mono_pmip
	0x1095b7398 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : mono_pmip
	0x1095bd878 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : mono_pmip
	0x1095b5bac - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : mono_pmip
	0x1095cf338 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : mono_pmip
	0x1095b46f0 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : mono_pmip
	0x105619314 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : 
	0x104cb3b24 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : 
	0x10555b5e0 - /private/var/cont
==============================
Memory around native instruction pointer (0x1ba6929e8):0x1ba6929d8  c0 03 5f d6 c0 03 5f d6 10 29 80 d2 01 10 00 d4  .._
ainers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : 
	0x1095ac334 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : mono_pmip
	0x109658d5c - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : mono_pmip
	0x10965dfd0 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : mono_pmip
	0x109590c28 - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : 
	0x10973d3ac - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : xamarin_localized_string_format_9
	0x104cb330c - /private/var/containers/Bundle/Application/9BE5515B-3508-4FB9-952E-CB09BB8E15A5/App1.iOS.app/App1.iOS : 
	0x10a0a4190 - Unknown

=================================================================
	Basic Fault Address Reporting
===================================
..._..)......
0x1ba6929e8  e3 
00 00 54 fd 7b bf a9 fd 03 00 91 
1f ef ff 97  ...T.{.......
...
0x1ba6929f8  bf 03 00 91 fd 7b 
...{...._..._.

c1 a8 c0 03 5f d6 c0 03 5f d6  ..
0x1ba692a08  fd 7b bf a9 fd 03 
00 91 50 00 80 d2 01 10 00 d4  .{
......P.......


=================================================================
	Managed Stacktrace:
=================================================================
	  at <unknown> <0xffffffff>
	  at System.AppDomain:LoadAssemblyRaw <0x00007>
	  at System.AppDomain:Load <0x0003b>
	  at System.AppDomain:Load <0x0002f>
	  at System.AppDomain:Load <0x00023>
	  at System.Reflection.Assembly:Load <0x00023>
	  at System.Object:runtime_invoke_dynamic <0x0010f>
	  at <unknown> <0xffffffff>

	  at App1.iOS.Application:Main <0x00053>
	  at System.Object:runtime_invoke_dynamic <0x0010f>
=================================================================

L'app è stata terminata.

Basic Information

  • Version with issue: 5.0.0.2196+786-sha.7958ff904-azdo.5328488
  • Last known good version: N/A
  • Platform Target Frameworks:
    • iOS: 15.0
    • Android: N/A
    • UWP: N/A
  • Android Support Library / AndroidX Version:
  • NuGet Packages: System.Text.Json (≥ 6.0.0)
  • Affected Devices: iPhone SE

Environment

Show/Hide Visual Studio info
Microsoft Visual Studio Professional 2022
Versione 17.0.0
VisualStudio.17.Release/17.0.0+31903.59
Microsoft .NET Framework
Versione 4.8.04084

Edizione installata: Professional

ASP.NET and Web Tools 2019   17.0.789.48259
ASP.NET and Web Tools 2019

ASP.NET Web Frameworks and Tools 2019   17.0.789.48259
Per altre informazioni, vedere https://www.asp.net/

Azure App Service Tools v3.0.0   17.0.789.48259
Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools   17.0.789.48259
Azure Functions and Web Jobs Tools

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Debug di .NET Core con WSL   1.0
Debug di .NET Core con WSL

Estensioni per Strumenti contenitore di Visual Studio   1.0
Consente di visualizzare, gestire ed eseguire la diagnosi dei contenitori all'interno di Visual Studio.

Extensibility Message Bus   1.2.6 (master@34d6af2)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

Gestione pacchetti NuGet   6.0.0
Gestione pacchetti NuGet in Visual Studio. Per altre informazioni su NuGet, visitare il sito Web https://docs.nuget.org/

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio Tools per contenitori   1.2
Consente di sviluppare, eseguire e convalidare applicazioni ASP.NET Core nell'ambiente di destinazione. Premere F5 per modificare l'applicazione direttamente in un contenitore senza debug oppure CTRL+F5 per modificare e aggiornare l'app senza ricompilare il contenitore.

Mono Debugging for Visual Studio   17.0.11 (54f19d2)
Support for debugging Mono processes with Visual Studio.

Pacchetto host dell'adattatore di debug di Visual Studio Code   1.0
Livello di interoperabilità per l'hosting degli adattatori di debug di Visual Studio Code in Visual Studio

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

Razor (ASP.NET Core)   17.0.0.2152201+3319c75f898522ff4dc9cf0c70035c284264a1de
Fornisce servizi di linguaggio per ASP.NET Core Razor.

SQL Server Data Tools   17.0.62110.20190
Microsoft SQL Server Data Tools

Strumenti C#   4.0.0-6.21526.21+c7d6f9fab845ffd943216da465022744e7d35f22
Componenti di C# usati nell'IDE. A seconda del tipo e delle impostazioni del processo, è possibile che venga usata una versione diversa del compilatore.

Strumenti di Visual Basic   4.0.0-6.21526.21+c7d6f9fab845ffd943216da465022744e7d35f22
Componenti di Visual Basic usati nell'IDE. A seconda del tipo e delle impostazioni del processo, è possibile che venga usata una versione diversa del compilatore.

Strumenti TypeScript   17.0.1001.2002
Strumenti TypeScript per Microsoft Visual Studio

Visual F# Tools   17.0.0-beta.21522.2+6d626ff0752a77d339f609b4d361787dc9ca93a5
Microsoft Visual F# Tools

Visual Studio Tools per contenitori   1.0
Visual Studio Tools per contenitori

VisualStudio.DeviceLog   1.0
Informazioni sul pacchetto

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

Xamarin   17.0.0.336 (d17-0@29731f2)
Estensione di Visual Studio per consentire lo sviluppo per Xamarin.iOS e Xamarin.Android.

Xamarin Designer   17.0.0.182 (remotes/origin/d17-0@ea204898d)
Estensione di Visual Studio per abilitare gli strumenti di Xamarin Designer in Visual Studio.

Xamarin Templates   17.0.17 (9e779b0)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK   12.1.0.5 (d17-0/6b0e6b2)
Xamarin.Android Reference Assemblies and MSBuild support.
    Mono: c633fe9
    Java.Interop: xamarin/java.interop/d17-0@febb1367
    ProGuard: Guardsquare/proguard/v7.0.1@912d149
    SQLite: xamarin/sqlite/3.36.0@a575761
    Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-0@a5194e9


Xamarin.iOS and Xamarin.Mac SDK   15.0.0.18 (577ff6329)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Build Logs

https://gist.github.com/evolutionerp/f7f62daf1c2f4415668bd985f444892f

Screenshots

N/A

Reproduction Link

Project that can reproduce the issue: App1-pub.zip

The App1.iOS project crashes as described, whereas App2.iOS (Xamarin iOS project without Xamarin.Forms) does not.

Workaround

Disabling "Hot Reload", as per this other feedback

evolutionerp avatar Nov 11 '21 10:11 evolutionerp

I've also seen this error since upgrading to the 6.0.0 version of System.Text.Json

lee-m avatar Nov 11 '21 11:11 lee-m

We have started the process of upgrading to VS 2022 as part of a .Net core migration, This issue is not present in our 2019 environment but is on VS 2022 17.0.0.

DavidStrachanLexacom avatar Nov 15 '21 12:11 DavidStrachanLexacom

Thanks for the report! As you mentioned, this has already been reported through the VS Community portal with which it should land at the right place. You probably want to wait for some feedback to come from there, I suspect there is not much we can do from the Forms side.

I see @jonathanpeppers in the linked issue is also asking: why are you debugging with AOT on?

jfversluis avatar Nov 15 '21 12:11 jfversluis

iOS is different here, as AOT is required on device. So debugging on an iOS device would use AOT.

@jfversluis I would maybe just transfer this to https://github.com/xamarin/xamarin-macios/issues, and let them know.

jonathanpeppers avatar Nov 15 '21 14:11 jonathanpeppers

@jonathanpeppers I have replied on the other ticket mentioned above. The OP was ambiguous and think it as well has been miss categorised as android, though only the author could confirm.

DavidStrachanLexacom avatar Nov 15 '21 14:11 DavidStrachanLexacom

@dalexsoto moving this here as it seems to have to do with you? If I was mistaken please let me know!

Also tagging @spouliot as I've seen him busy in #12353 to which this might be related to?

jfversluis avatar Nov 15 '21 14:11 jfversluis

So this error is reported by the runtime when the app tries to load an assembly which doesn't match the assembly the aot code was generated from. Its either a problem in the build system, i.e. the wrong assembly is packaged into the app, or maybe the app contains 2 copies of an assembly, and tries to load the wrong copy.

vargaz avatar Nov 15 '21 18:11 vargaz

This was also reported in these two developer community issues (closed and pointing here):

https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1429785 https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1435614

chamons avatar Nov 16 '21 16:11 chamons

Hey folks,

I believe this might be the same underlying issue as https://developercommunity.visualstudio.com/t/bug-in-visual-studio-2022-xamarin-signalr-method-n/1528510#T-N1585840.

@evolutionerp - Can you disable XAML hot reload as noted in ^ and see if you can reproduce?

chamons avatar Nov 18 '21 15:11 chamons

@chamons I can confirm the workaround has solved the AOT module issue for myself. Which matched the OP's error.

DavidStrachanLexacom avatar Nov 18 '21 16:11 DavidStrachanLexacom

Yes, by disabling hot-reload the debugger seems to attach correctly.

I've updated the issue to include this workaround.

evolutionerp avatar Nov 19 '21 07:11 evolutionerp

God, yes, same here!

ShadowOfPhantom avatar Nov 21 '21 15:11 ShadowOfPhantom

Still an issue with: `Microsoft Visual Studio Community 2022 (64-bit) Version 17.0.1

Xamarin 17.0.0.341 (d17-0@ac52790) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 17.0.0.182 (remotes/origin/d17-0@ea204898d) Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates 17.0.17 (9e779b0) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 12.1.0.5 (d17-0/6b0e6b2) Xamarin.Android Reference Assemblies and MSBuild support. Mono: c633fe9 Java.Interop: xamarin/java.interop/d17-0@febb1367 ProGuard: Guardsquare/proguard/v7.0.1@912d149 SQLite: xamarin/sqlite/3.36.0@a575761 Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-0@a5194e9

Xamarin.iOS and Xamarin.Mac SDK 15.2.0.17 (738fde344) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support. ` Workaround with disabling HotReload works. However, I hope that this workaround will not hold the fix to this issue which is holding from start using VS 2022

IngweLand avatar Nov 22 '21 10:11 IngweLand

Same problem here, with exact same setup as @IngweLand. Disabling HotReload works. Packages:

<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="Xamarin.CommunityToolkit" Version="1.3.0" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2244" />  
<PackageReference Include="Xamarin.Essentials" Version="1.7.0" />  
<PackageReference Include="Xamarin.Forms.PancakeView" Version="2.3.0.759" />  
<PackageReference Include="Xamarin.Forms.Visual.Material" Version="5.0.0.2244" />

psandgren avatar Nov 24 '21 10:11 psandgren

Same here - disabling XAML Hot Reload worked (with .NET Hot Reload still enabled).

chrfin avatar Nov 28 '21 10:11 chrfin

Microsoft, please fix it!

scriptBoris avatar Nov 29 '21 15:11 scriptBoris

Same problem here!

wagenheimer avatar Dec 01 '21 21:12 wagenheimer

Status of This? Just checked against 17.0.2 and it still exists. IMO, this is a P1 or P2. HotReload is not working, and there is no Forms Editor Anymore. Doing XAML Forms blind, and waiting to deploy, to see if look nice. Is taking too many hours.

maxpiva avatar Dec 02 '21 15:12 maxpiva

@chamons @jfversluis do we have a road map for this? it has really doubled my development time as changing UI elements requires a full redeploy rather than hot reload.

DavidStrachanLexacom avatar Dec 13 '21 14:12 DavidStrachanLexacom

@davidortinau FYI ^

chamons avatar Dec 13 '21 15:12 chamons

@chamons, @davidortinau, @imhameed

Do we have any update on this issue? currently having to stop and redeploy each minor UI change is not much fun

DavidStrachanLexacom avatar Jan 21 '22 09:01 DavidStrachanLexacom

Visual Studio 2022 Version 17.0.5 still exihibits this behavior. I have so far been unable to get my project to debug, even AFTER disabling Hot Reload. I did update from Xamarin 4 to 5 and all the headaches that came with that...especially Xamarin.Essentials and Xamarin.Android.Support... Please fix this ASAP. Please...pla-ease.

sdavis72 avatar Feb 08 '22 15:02 sdavis72

This is a wild shot, but can you try this fix to see if if works around the problem: https://github.com/xamarin/xamarin-macios/issues/11691#issuecomment-1032606607?

rolfbjarne avatar Feb 08 '22 16:02 rolfbjarne

@drasticactions do you inject System.Memory for XAML Hot Reload? (pre-net6 ios project)

lambdageek avatar Mar 01 '22 21:03 lambdageek

While binding a native iOS library to MAUI, I get this error too when running the app in debug on physical device error: Failed to load AOT module 'data-0x137134000.dylib' ('data-0x137134000') in aot-only mode.

It is working on a simulator, or in release on physical device.

I confirm disabling the hot reload allow me to run the app in debug mode on physical device, and the debugger is attached.

I tried to add <ResolveAssemblyConflicts>true</ResolveAssemblyConflicts> to the csproj, reactivate hot reload, debug on physical device, but I get the same error "failed to load AOT module".

(Visual studio for mac, 17.6.3)

espritm avatar Sep 14 '23 08:09 espritm

@espritm do you get that error even if you clean your solution first?

rolfbjarne avatar Sep 14 '23 08:09 rolfbjarne

I tested again : solution cleaned, bin and obj folders removed from all solution projects, but still have error: Failed to load AOT module 'data-0x13932c000.dylib' ('data-0x13932c000') in aot-only mode. when running the app in debug on physical device with Hot Relead activated.

espritm avatar Sep 14 '23 08:09 espritm

@espritm do you get the same result if you try a new project from a template?

rolfbjarne avatar Sep 14 '23 11:09 rolfbjarne

I tested with a new project from the MAUI template, and indeed it works

espritm avatar Sep 14 '23 17:09 espritm

I tested with a new project from the MAUI template, and indeed it works

That means we'll need a test project in order to reproduce this.

rolfbjarne avatar Sep 15 '23 08:09 rolfbjarne