-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.NET 9: Runtime crashes when utilizing legacy libraries. #24740
Comments
Hi I'm an AI powered bot that finds similar issues based off the issue title. Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you! Open similar issues:
Closed similar issues:
|
@daltzctr can you share the stack trace of some of these crashes? Do we know if this change was in RC 1, it was merged only 2 weeks ago, so perhaps not: The idea is it should restore a lot of previous behavior from .NET 8. |
No, I don't see it in RC 1: |
Sharpnado (obsolete references, so not datatype related)
Maui.DataGrid (
|
Fixes: dotnet#24740 Using this in a project: <PackageReference Include="akgul.Maui.DataGrid" Version="4.0.4" /> Then, in a XAML file: xmlns:dg="clr-namespace:Maui.DataGrid;assembly=Maui.DataGrid" ... <dg:DataGrid /> Would crash with: [0:] [13:46:57 FTL] Inner Exception: System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Maui.Controls.Xaml.BindingExtension.<Microsoft.Maui.Controls.Xaml.IMarkupExtension<Microsoft.Maui.Controls.BindingBase>.ProvideValue>g__CreateBinding|40_0(<>c__DisplayClass40_0& ) in /_/src/Controls/src/Xaml/MarkupExtensions/BindingExtension.cs:line 46 at Microsoft.Maui.Controls.Xaml.BindingExtension.Microsoft.Maui.Controls.Xaml.IMarkupExtension<Microsoft.Maui.Controls.BindingBase>.ProvideValue(IServiceProvider serviceProvider) in /_/src/Controls/src/Xaml/MarkupExtensions/BindingExtension.cs:line 27 at Maui.DataGrid.DataGrid.InitializeComponent() in D:\Maui.DataGrid\Maui.DataGrid\Microsoft.Maui.Controls.SourceGen\Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator\DataGrid.xaml.sg.cs:line 53 at Maui.DataGrid.DataGrid..ctor() in D:\Maui.DataGrid\Maui.DataGrid\DataGrid.xaml.cs:line 46 at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Constructor(Object obj, IntPtr* args) at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr) Inspecting the IL, I see: BindingBase val115 = ((IMarkupExtension<BindingBase>)(object)val31).ProvideValue((IServiceProvider)null); So, it is indeed passed a `null` `IServiceProvider`. Introduce a unit test and check for `null` as a fix.
@daltzctr this should hopefully fix For |
Fixes: dotnet#24740 Using this in a project: <PackageReference Include="akgul.Maui.DataGrid" Version="4.0.4" /> Then, in a XAML file: xmlns:dg="clr-namespace:Maui.DataGrid;assembly=Maui.DataGrid" ... <dg:DataGrid /> Would crash with: [0:] [13:46:57 FTL] Inner Exception: System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Maui.Controls.Xaml.BindingExtension.<Microsoft.Maui.Controls.Xaml.IMarkupExtension<Microsoft.Maui.Controls.BindingBase>.ProvideValue>g__CreateBinding|40_0(<>c__DisplayClass40_0& ) in /_/src/Controls/src/Xaml/MarkupExtensions/BindingExtension.cs:line 46 at Microsoft.Maui.Controls.Xaml.BindingExtension.Microsoft.Maui.Controls.Xaml.IMarkupExtension<Microsoft.Maui.Controls.BindingBase>.ProvideValue(IServiceProvider serviceProvider) in /_/src/Controls/src/Xaml/MarkupExtensions/BindingExtension.cs:line 27 at Maui.DataGrid.DataGrid.InitializeComponent() in D:\Maui.DataGrid\Maui.DataGrid\Microsoft.Maui.Controls.SourceGen\Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator\DataGrid.xaml.sg.cs:line 53 at Maui.DataGrid.DataGrid..ctor() in D:\Maui.DataGrid\Maui.DataGrid\DataGrid.xaml.cs:line 46 at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Constructor(Object obj, IntPtr* args) at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr) Inspecting the IL, I see: BindingBase val115 = ((IMarkupExtension<BindingBase>)(object)val31).ProvideValue((IServiceProvider)null); So, it is indeed passed a `null` `IServiceProvider`. Introduce a unit test and check for `null` as a fix.
Fixes: #24740 Using this in a project: <PackageReference Include="akgul.Maui.DataGrid" Version="4.0.4" /> Then, in a XAML file: xmlns:dg="clr-namespace:Maui.DataGrid;assembly=Maui.DataGrid" ... <dg:DataGrid /> Would crash with: [0:] [13:46:57 FTL] Inner Exception: System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Maui.Controls.Xaml.BindingExtension.<Microsoft.Maui.Controls.Xaml.IMarkupExtension<Microsoft.Maui.Controls.BindingBase>.ProvideValue>g__CreateBinding|40_0(<>c__DisplayClass40_0& ) in /_/src/Controls/src/Xaml/MarkupExtensions/BindingExtension.cs:line 46 at Microsoft.Maui.Controls.Xaml.BindingExtension.Microsoft.Maui.Controls.Xaml.IMarkupExtension<Microsoft.Maui.Controls.BindingBase>.ProvideValue(IServiceProvider serviceProvider) in /_/src/Controls/src/Xaml/MarkupExtensions/BindingExtension.cs:line 27 at Maui.DataGrid.DataGrid.InitializeComponent() in D:\Maui.DataGrid\Maui.DataGrid\Microsoft.Maui.Controls.SourceGen\Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator\DataGrid.xaml.sg.cs:line 53 at Maui.DataGrid.DataGrid..ctor() in D:\Maui.DataGrid\Maui.DataGrid\DataGrid.xaml.cs:line 46 at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Constructor(Object obj, IntPtr* args) at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr) Inspecting the IL, I see: BindingBase val115 = ((IMarkupExtension<BindingBase>)(object)val31).ProvideValue((IServiceProvider)null); So, it is indeed passed a `null` `IServiceProvider`. Introduce a unit test and check for `null` as a fix.
I believe this also would fix Sharpnado.Tabs, checking But if @daltzctr has a sample, I could test for sure. Closing, thanks! |
Description
MAUI class libraries that utilize the following features
Frame
Device
x:DataType={x:Object}
which would previously fall back to reflection based bindings.Will runtime crash when used in a consumer project. The consumer project has no warnings about any incompatibilities and will just crash.
Some examples of offending libraries are
Border
andDevice
)x:DataType={x:Object}
Proposal:
I am not sure of the technical challenges on this, but it would be nice to either mark .NET 8 MAUI libraries with warnings as possibly incompatible, or detect incompatibilities in referenced libraries and throw a compile time error. This is no workaround and library maintainers must fix the issues by fixing the obsoleted references and ensure they are datatyping everything (replace
x:DataType={x:Object}
withx:DataType={x:Null}
to explicitly opt in to reflection based bindings as a short term workaround.Steps to Reproduce
Link to public reproduction project repository
No response
Version with bug
9.0.0-rc.1.24453.9
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
8.0.82 SR8.2
Affected platforms
iOS, Android
Affected platform versions
No response
Did you find any workaround?
No. The only workaround has been to fix the references upstream.
Relevant log output
No response
The text was updated successfully, but these errors were encountered: