RadzenDropDownDataGrid crashes when used with .NET 6.0. Works with .NET 7.0 and above. #1899

Closed
opened 2026-01-29 17:59:56 +00:00 by claunia · 1 comment
Owner

Originally created by @ffozma on GitHub (Nov 5, 2025).

Bug Description

When adding a RadzenDropDownDataGrid component to a page within a project under .NET 6.0, it throws a System.ArgumentException when calling the FirstOrDefault method under QueryableExtension.cs. This does not happen when .NET version is changed to 7.0 or above.

Additional Context

From my testing, I think this is due to having a typeof(Queryable).GetTypeInfo().GetDeclaredMethods(nameof(Queryable.FirstOrDefault)).FirstOrDefault(mi => mi.IsGenericMethod) that assumes the first generic method returned will be one with the same set of arguments as used by the Expression.Call. According to this (could not find a direct reference to GetDeclaredMethods but I'm assuming it is the same), while the ordering is deterministic for 7.0+, it is not for 6.0:

In .NET 6 and earlier versions, the [GetMethods](https://learn.microsoft.com/en-us/dotnet/api/system.type.getmethods?view=net-9.0) method does not return methods in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which methods are returned, because that order varies. However, starting with .NET 7, the ordering is deterministic based upon the metadata ordering in the assembly.

In this particular case, .NET 7.0+ returns the desired method first:

Image

While .NET 6.0 returns the desired method as last:

Image

This issue is surely happening in other parts of Radzen, although I've only tested with RadzenDropDownDataGrid.

Proposed solution:

One solution would be to check the number of arguments for all similar calls:

typeof(Queryable).GetTypeInfo().GetDeclaredMethods(nameof(Queryable.FirstOrDefault)).FirstOrDefault(mi => mi.IsGenericMethod && mi.GetParameters().Length == 1).MakeGenericMethod(source.ElementType)

Code snippet:

@page "/"
@using Radzen.Blazor

<RadzenDropDownDataGrid TValue="string" Data=@TestOptions TextProperty="Text" ValueProperty="Value" @bind-Value=@Test>
</RadzenDropDownDataGrid>

@code {
    public string Test { get; set; } = "1";

    public class DropDownTest
    {
        public string Text { get; set; }
        public string Value { get; set; }
    }

    public IEnumerable<DropDownTest> TestOptions { get; set; } = new List<DropDownTest>() {
            new DropDownTest() { Text = "A", Value = "1" },
            new DropDownTest() { Text = "B", Value = "2" },
            new DropDownTest() { Text = "C", Value = "3" }};
}

Exception:

File: QueryableExtension.cs
Method: public static dynamic FirstOrDefault(this IQueryable source)
Message: System.ArgumentException: 'Incorrect number of arguments supplied for call to method 'DropDownTest FirstOrDefault[DropDownTest](System.Linq.IQueryable`1[BlazorApp1.Pages.Index+DropDownTest], DropDownTest)' (Parameter 'method')'

Expected behavior:

Should show a dropdown without triggering an exception under .NET 6.0.

To reproduce:

  • Create a Blazor.Server project
  • Add Radzen.Blazor as a dependency
  • Edit "_Layout.cshtml" to add <script src="_content/Radzen.Blazor/Radzen.Blazor.js"></script>
  • Edit Index page with the code snippet above.
  • Set project version to NET 6.0 and run. This should trigger the exception.
  • Set project version to NET 7.0 (or above) and run. This should not trigger the exception.

Desktop:

  • OS: Microsoft Windows 11 Enterprise 10.0.26100
  • Browser: Chrome (should happen on others as well)
  • Version: 141.0.7390.123
Originally created by @ffozma on GitHub (Nov 5, 2025). ### Bug Description When adding a **RadzenDropDownDataGrid** component to a page within a project under **.NET 6.0**, it throws a **System.ArgumentException** when calling the **FirstOrDefault** method under **QueryableExtension.cs**. This does not happen when .NET version is changed to 7.0 or above. ### Additional Context From my testing, I think this is due to having a `typeof(Queryable).GetTypeInfo().GetDeclaredMethods(nameof(Queryable.FirstOrDefault)).FirstOrDefault(mi => mi.IsGenericMethod)` that assumes the first generic method returned will be one with the same set of arguments as used by the **Expression.Call**. According to [this](https://learn.microsoft.com/en-us/dotnet/api/system.type.getmethods?view=net-9.0) (could not find a direct reference to GetDeclaredMethods but I'm assuming it is the same), while the ordering is deterministic for 7.0+, it is not for 6.0: ``` In .NET 6 and earlier versions, the [GetMethods](https://learn.microsoft.com/en-us/dotnet/api/system.type.getmethods?view=net-9.0) method does not return methods in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which methods are returned, because that order varies. However, starting with .NET 7, the ordering is deterministic based upon the metadata ordering in the assembly. ``` In this particular case, .NET 7.0+ returns the desired method first: <img width="1057" height="92" alt="Image" src="https://github.com/user-attachments/assets/4dd64edf-b1a7-40eb-86f7-33ac3ebc15b3" /> While .NET 6.0 returns the desired method as last: <img width="1057" height="85" alt="Image" src="https://github.com/user-attachments/assets/41ee418c-54ff-45ee-85b5-1a9f710d401f" /> This issue is surely happening in other parts of Radzen, although I've only tested with RadzenDropDownDataGrid. ### Proposed solution: One solution would be to check the number of arguments for all similar calls: ``` typeof(Queryable).GetTypeInfo().GetDeclaredMethods(nameof(Queryable.FirstOrDefault)).FirstOrDefault(mi => mi.IsGenericMethod && mi.GetParameters().Length == 1).MakeGenericMethod(source.ElementType) ``` ### Code snippet: ``` @page "/" @using Radzen.Blazor <RadzenDropDownDataGrid TValue="string" Data=@TestOptions TextProperty="Text" ValueProperty="Value" @bind-Value=@Test> </RadzenDropDownDataGrid> @code { public string Test { get; set; } = "1"; public class DropDownTest { public string Text { get; set; } public string Value { get; set; } } public IEnumerable<DropDownTest> TestOptions { get; set; } = new List<DropDownTest>() { new DropDownTest() { Text = "A", Value = "1" }, new DropDownTest() { Text = "B", Value = "2" }, new DropDownTest() { Text = "C", Value = "3" }}; } ``` ### Exception: **File:** QueryableExtension.cs **Method:** public static dynamic FirstOrDefault(this IQueryable source) **Message:** System.ArgumentException: 'Incorrect number of arguments supplied for call to method 'DropDownTest FirstOrDefault[DropDownTest](System.Linq.IQueryable`1[BlazorApp1.Pages.Index+DropDownTest], DropDownTest)' (Parameter 'method')' ### Expected behavior: Should show a dropdown without triggering an exception under .NET 6.0. ### To reproduce: - Create a Blazor.Server project - Add Radzen.Blazor as a dependency - Edit "_Layout.cshtml" to add <script src="_content/Radzen.Blazor/Radzen.Blazor.js"></script> - Edit Index page with the code snippet above. - Set project version to NET 6.0 and run. This should trigger the exception. - Set project version to NET 7.0 (or above) and run. This should **not** trigger the exception. ### Desktop: - OS: Microsoft Windows 11 Enterprise 10.0.26100 - Browser: Chrome (should happen on others as well) - Version: 141.0.7390.123
Author
Owner

@enchev commented on GitHub (Nov 6, 2025):

.NET 6 reached its end-of-life on November 12, 2024 frankly speaking NET 7 reached its end of life on May 14, 2024, and both are no longer supported by Microsoft. Not sure if we should continue to have builds for them or we can simply remove them for our next week release for .NET 10.

@enchev commented on GitHub (Nov 6, 2025): .NET 6 reached its end-of-life on November 12, 2024 frankly speaking NET 7 reached its end of life on May 14, 2024, and both are no longer supported by Microsoft. Not sure if we should continue to have builds for them or we can simply remove them for our next week release for .NET 10.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1899