android: Can't debug with VS 2022 17.1.0 Prev 1.0

I can’t debug at all. Hangs on the splash screen. A breakpoint in OnCreate of the MainActivity is never hit as I get the following in the debugger.

System.InvalidProgramException
  Message=Invalid IL code in Mono.SystemDependencyProvider:Initialize (): IL_002e: endfinally

A release build runs fine, except for what was reported in #6479.

Tried on another machine, and get the same result. Both machines Windows 11

Reverted back to VS 2022 17.0.0 and can debug normally again.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 42 (24 by maintainers)

Commits related to this issue

Most upvoted comments

@agneszitte-nventive if turning on Fast Deployment solves your issue (EmbedAssembliesIntoApk=true is Fast Dev off, it toggles opposite of the property).

Then I think the issue might be related to: https://github.com/dotnet/runtime/issues/62201

As another workaround, if you want Fast Deployment off (like if you need to Debug on an older device), you could try checking every ABI:

image

Same thing is happening to me: A couple of months ago I created a AppShell (Flyout) app and it was working fine on VS2019 up to date (as for 19 Nov. 2021). I transitioned to VS2022 preview (macos) and I get the same problem.

Ive downloaded .Net 6 for the m1 architecture.

[mono] Unhandled Exception:
[mono] System.InvalidProgramException: Invalid IL code in Mono.SystemDependencyProvider:Initialize (): IL_002e: endfinally
[mono] 
[mono] 
[mono]   at Android.Runtime.JNIEnv.Initialize (Android.Runtime.JnienvInitializeArgs* args) [0x000e8] in /Users/builder/azdo/_work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.cs:173 
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidProgramException: Invalid IL code in Mono.SystemDependencyProvider:Initialize (): IL_002e: endfinally
[mono-rt] 
[mono-rt] 
[mono-rt]   at Android.Runtime.JNIEnv.Initialize (Android.Runtime.JnienvInitializeArgs* args) [0x000e8] in /Users/builder/azdo/_work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.cs:173 


edit: Just to add to the discussion, a colleague using VS2022 17.0.0 (on a Windows 11 machine) is not having this issue. Exactly the same code as me