Skip to content

Type binding Error with .NET 9 Preview 6 #23551

@davidortinau

Description

@davidortinau

Description

Testing .NET Hot Reload and .NET 9 Preview 6 I'm getting these errors:

Exception has occurred: CLR/System.TypeLoadException
An unhandled exception of type 'System.TypeLoadException' occurred in Mono.Android.Runtime.dll: 'Could not resolve type with token 01000075 from typeref (expected class 'Microsoft.Maui.Controls.Generated.<GeneratedBindableObjectExtensions_g>F340249EF3F4705EB00F29166AE5B0DC4FEF24016399EDCA95F8D25AC35F9B242__GeneratedBindableObjectExtensions' in assembly '')'
   at Android.Runtime.RuntimeNativeMethods.monodroid_debugger_unhandled_exception(Exception e)
   at Android.Runtime.JNINativeWrapper._unhandled_exception(Exception e)
   at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(_JniMarshal_PP_V callback, IntPtr jnienv, IntPtr klazz)
   at SharpNine.FirstPage.Build() in /Users/davidortinau/work/SharpNine/FirstPage.cs:line 41
   at SharpNine.FirstPage.<.ctor>b__2_1()
   at Java.Lang.Thread.RunnableImplementor.Run()
   at Java.Lang.IRunnableInvoker.n_Run(IntPtr jnienv, IntPtr native__this)
   at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(_JniMarshal_PP_V callback, IntPtr jnienv, IntPtr klazz)
Exception has occurred: CLR/System.TypeLoadException
An unhandled exception of type 'System.TypeLoadException' occurred in Microsoft.iOS.dll: 'Could not resolve type with token 01000072 from typeref (expected class 'Microsoft.Maui.Controls.Generated.<GeneratedBindableObjectExtensions_g>F340249EF3F4705EB00F29166AE5B0DC4FEF24016399EDCA95F8D25AC35F9B242__GeneratedBindableObjectExtensions' in assembly '')'
   at ObjCRuntime.Runtime.ThrowException(IntPtr gchandle)
   at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName)
   at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass)
   at SharpNine.Program.Main(String[] args) in /Users/davidortinau/work/SharpNine/Platforms/iOS/Program.cs:line 14

From changing anything in this method:

void Build()
	{
		Content = new VerticalStackLayout
		{
			Spacing = 20,
			Margin = 20,
			Children = {
				(label = new Label {  
					Text = "Welcome to .NET MAUI!",
					FontSize = 64,
					TextColor = Colors.Blue
				}),
				(entry = new Entry { Placeholder = "Enter your name" }),
			}
		};

		label.SetBinding(Label.TextProperty, static (Entry e) => e.Text, source: entry);
	}

The binding functions as I expect. @simonrozsival I suspect this is related to the compiled bindings work.

Commenting out the binding allows .NET Hot Reload to succeed without error. Returning to a non-compiled binding works as well:

label.SetBinding(Label.TextProperty, new Binding("Text", source: entry));

SharpNine.zip

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

9.0.0-preview.6.24327.7

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android, macOS

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

Metadata

Metadata

Assignees

Labels

area-xamlXAML, CSS, Triggers, Behaviorsi/regressionThis issue described a confirmed regression on a currently supported versionplatform/androidplatform/iosplatform/macosmacOS / Mac Catalysts/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions