maui icon indicating copy to clipboard operation
maui copied to clipboard

InvalidProgramException when binding to a static property

Open SaschaWegener opened this issue 2 years ago • 2 comments

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

  1. Create a new MAUI project from the Visual Studio template
  2. 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.
  3. Add a static property in the view model and bind to it from the view.
  4. 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

SaschaWegener avatar Dec 14 '22 14:12 SaschaWegener

@StephaneDelcroix Thoughts?

jsuarezruiz avatar Dec 14 '22 19:12 jsuarezruiz

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.

ghost avatar Dec 14 '22 19:12 ghost

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 image

homeyf avatar Aug 11 '23 06:08 homeyf