question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid IL code in AllControls sample

See original GitHub issue

I’m getting the following exception when starting the AllControls sample, for both iOS, Android and macOS (and I guess the other platforms too?):

System.InvalidProgramException: Invalid IL code in AllControls.AppModule:view (AllControls.Model,Microsoft.FSharp.Core.FSharpFunc`2<AllControls.Msg, Microsoft.FSharp.Core.Unit>): IL_28a2: stloc     953


  at <StartupCode$AllControls>.$AllControls+-ctor@1062-2.Invoke (AllControls.Model model, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] dispatch) [0x00000] in /Users/timothelariviere/Git/GitHub/Fabulous/Fabulous.XamarinForms/samples/AllControls/AllControls/AllControls.fs:1062
  at Fabulous.ProgramModule+traceView@210[model,msg,arg].Invoke (model model, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] dispatch) [0x00082] in /Users/timothelariviere/Git/GitHub/Fabulous/src/Fabulous/Program.fs:217
  at Fabulous.ProgramRunner`3[arg,model,msg]..ctor (Fabulous.IHost host, Fabulous.Program`3[arg,model,msg] program, Microsoft.FSharp.Core.Unit arg) [0x00078] in /Users/timothelariviere/Git/GitHub/Fabulous/src/Fabulous/Program.fs:55
  at Fabulous.ProgramModule.runWithFabulous[arg,model,msg] (Fabulous.IHost host, arg arg, Fabulous.Program`3[arg,model,msg] program) [0x00000] in /Users/timothelariviere/Git/GitHub/Fabulous/src/Fabulous/Program.fs:252
  at Fabulous.XamarinForms.XamarinFormsProgramModule.runWith[a,b,c] (Xamarin.Forms.Application app, a arg, Fabulous.Program`3[arg,model,msg] program) [0x00007] in /Users/timothelariviere/Git/GitHub/Fabulous/Fabulous.XamarinForms/src/Fabulous.XamarinForms.Core/Program.fs:35
  at Fabulous.XamarinForms.XamarinFormsProgramModule.run[a,b] (Xamarin.Forms.Application app, Fabulous.Program`3[arg,model,msg] program) [0x00000] in /Users/timothelariviere/Git/GitHub/Fabulous/Fabulous.XamarinForms/src/Fabulous.XamarinForms.Core/Program.fs:42
  at AllControls.App..ctor () [0x0003b] in /Users/timothelariviere/Git/GitHub/Fabulous/Fabulous.XamarinForms/samples/AllControls/AllControls/AllControls.fs:1061
  at iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication uiApp, Foundation.NSDictionary options) [0x00034] in /Users/timothelariviere/Git/GitHub/Fabulous/Fabulous.XamarinForms/samples/AllControls/iOS/AppDelegate.fs:18
  at at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.4.0.2/src/Xamarin.iOS/UIKit/UIApplication.cs:86
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.4.0.2/src/Xamarin.iOS/UIKit/UIApplication.cs:65
  at iOS.Main.main (System.String[] args) [0x00000] in /Users/timothelariviere/Git/GitHub/Fabulous/Fabulous.XamarinForms/samples/AllControls/iOS/AppDelegate.fs:32

The view function seems to produce invalid IL.

I don’t know why, it stopped working after #530 apparently. Almost same code in https://github.com/fsprojects/Fabulous/tree/0.43.0 doesn’t trigger the issue.

I played a little with the view function, and found that if I extract the code for the last match case (that we added recently, but there wasn’t the issue at that moment) into its own function, the issue disappears…

https://github.com/fsprojects/Fabulous/blob/5886acc0aecdb57da33799f52c080e6101d412b8/Fabulous.XamarinForms/samples/AllControls/AllControls/AllControls.fs#L1035-L1054

Versions log
Visual Studio Enterprise 2019 for Mac
Version 8.3.5 (build 13)
Installation UUID: 97b76ad0-1550-4a4e-8af6-781cda196581
	GTK+ 2.24.23 (Raleigh theme)
	Xamarin.Mac 5.16.1.24 (d16-3 / 08809f5b)

	Package version: 604000208

Mono Framework MDK
Runtime:
	Mono 6.4.0.208 (2019-06/07c23f2ca43) (64-bit)
	Package version: 604000208

NuGet
Version: 5.3.0.6192

.NET Core SDK
SDK: /usr/local/share/dotnet/sdk/3.0.100/Sdks
SDK Versions:
	3.0.100
	2.2.301
	2.2.206
	2.2.109
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.4.0/lib/mono/msbuild/Current/bin/Sdks

.NET Core Runtime
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	3.0.0
	2.2.7
	2.2.6
	2.1.13

Xamarin.Profiler
Version: 1.6.12.29
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater
Version: 11

Xamarin Designer
Version: 16.3.0.247
Hash: 52eac1a9e
Branch: remotes/origin/d16-3
Build date: 2019-10-03 23:04:28 UTC

Apple Developer Tools
Xcode 11.1 (15405)
Build 11A1027

Xamarin.Mac
Version: 6.4.0.2 (Visual Studio Enterprise)
Hash: e37549bc
Branch: xcode11.1
Build date: 2019-10-07 22:43:23-0400

Xamarin.iOS
Version: 13.4.0.2 (Visual Studio Enterprise)
Hash: e37549bc
Branch: xcode11.1
Build date: 2019-10-07 22:43:23-0400

Xamarin.Android
Version: 10.0.3.0 (Visual Studio Enterprise)
Commit: xamarin-android/d16-3/4d45b41
Android SDK: /Users/timothelariviere/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		None installed

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.1
SDK Build Tools Version: 28.0.3

Build Information: 
Mono: mono/mono/2019-06@5608fe0abb3
Java.Interop: xamarin/java.interop/d16-3@5836f58
LibZipSharp: grendello/LibZipSharp/d16-3@71f4a94
LibZip: nih-at/libzip/rel-1-5-1@b95cf3fd
ProGuard: xamarin/proguard/master@905836d
SQLite: xamarin/sqlite/3.27.1@8212a2d
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-3@cb41333

Microsoft Mobile OpenJDK
Java SDK: /Users/timothelariviere/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Android SDK Manager
Version: 1.4.0.65
Hash: c33b107
Branch: remotes/origin/d16-3
Build date: 2019-10-10 12:15:44 UTC

Android Device Manager
Version: 1.2.0.116
Hash: d2b2af0
Branch: remotes/origin/d16-3
Build date: 2019-10-10 12:16:06 UTC

Xamarin Inspector
Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1

Build Information
Release ID: 803050013
Git revision: 9ea9458e434c7b9f4e53ace3a461e2cdf966317f
Build date: 2019-10-24 13:08:01+00
Build branch: release-8.3
Xamarin extensions: ade6d975df7634a5d81feda320a6102e5bacf309

Operating System
Mac OS X 10.15.0
Darwin 19.0.0 Darwin Kernel Version 19.0.0
    Wed Sep 25 20:18:50 PDT 2019
    root:xnu-6153.11.26~2/RELEASE_X86_64 x86_64

Anyone getting the same issue?

@dsyme This one might interest you

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
dsymecommented, Oct 30, 2019

If we can trim this down to a minimal repro that would be, well, fabulous…

0reactions
dsymecommented, Oct 31, 2019

So I guess it’s ok?

Yes, it must be a mono/Xamarin limitation

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Invalid IL code generated
My decompiler is not able to decompile this (dotPeek) so I am assuming that the IL I generated is invalid. However, I'm not...
Read more >
Odd error: Invalid IL Code
Ok, I have a global Gameobject which is my active player. This gets populated on startup with the last player resource in the...
Read more >
InvalidProgramException (invalid IL code) ...
Examples of System. InvalidProgramException invalid IL in code include: method body is empty (most frequent), IL_0022: brtrue IL_00e9 , IL_0021 ...
Read more >
InvalidProgramException: Invalid IL code - Ask
Alright for anyone else experiencing this problem: it appears to be a bug with Mirror, since the same issue is open on their...
Read more >
Unity InvalidProgramException Invalid IL code in Mono.Data ...
Resolving InvalidProgramException Invalid IL code in Mono.Data.Sqlite.SqliteConnection:CreateDbCommand (): IL_0000: ret by changing the dll ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found