maui
maui copied to clipboard
InvalidProgramException when binding to a static property
Description
I have a ContentPage
called MainPage
and a MainPageViewModel
which is set as the BindingContext
and as the x:DataType
in the view. When adding a binding to a static property in the view model, the application crashes with an InvalidProgramException
with the message "The JIT compiler encountered invalid IL code or an internal limitation.".
This only happens in release builds.
Steps to Reproduce
- Create a new MAUI project from the Visual Studio template
- Add a view model for the main page and set it as the binding context and as the data type for binding. This will create compiled bindings.
- Add a static property in the view model and bind to it from the view.
- Run the application in Release build.
Link to public reproduction project repository
https://github.com/SaschaWegener/StaticBindingExample
Version with bug
7.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android, Windows
Affected platform versions
Android 11, windows10.0.19041.0, not tested on other platforms
Did you find any workaround?
Make all property non-static.
Relevant log output
System.InvalidProgramException
HResult=0x8013153A
Message=The JIT compiler encountered invalid IL code or an internal limitation.
Source=StaticBinding
StackTrace:
at StaticBinding.MainPage.<InitializeComponent>typedBindingsM__0(MainPageViewModel )
at Microsoft.Maui.Controls.Internals.TypedBinding`2.ApplyCore(Object sourceObject, BindableObject target, BindableProperty property, Boolean fromTarget) in Microsoft.Maui.Controls.Internals\TypedBinding.cs:line 184
@StephaneDelcroix Thoughts?
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
Verified this issue with Visual Studio Enterprise 17.7.0 Preview 6.0. Can repro on Android platform with sample project.
https://github.com/SaschaWegener/StaticBindingExample