CodeBeamOrg / CodeBeam.MudBlazor.Extensions

Useful third party extension components for MudBlazor, from the contributors.
https://mudextensions.codebeam.org/
MIT License
367 stars 62 forks source link

MudCsvMapper throws an Error in Blazor Server. #334

Closed nadavhury closed 5 months ago

nadavhury commented 6 months ago

Hi,

this is my code: `

@L["Close"] @L["Save"]

`

And I get this error When the Dialog try to come up:

Error: System.InvalidOperationException: Unable to set property 'ButtonTemplate' on object of type 'MudBlazor.MudFileUpload1[[Microsoft.AspNetCore.Components.Forms.IBrowserFile, Microsoft.AspNetCore.Components.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]]'. The error was: Unable to cast object of type 'Microsoft.AspNetCore.Components.RenderFragment1[System.String]' to type 'Microsoft.AspNetCore.Components.RenderFragment1[MudBlazor.FileUploadButtonTemplateContext1[Microsoft.AspNetCore.Components.Forms.IBrowserFile]]'. ---> System.InvalidCastException: Unable to cast object of type 'Microsoft.AspNetCore.Components.RenderFragment1[System.String]' to type 'Microsoft.AspNetCore.Components.RenderFragment1[MudBlazor.FileUploadButtonTemplateContext1[Microsoft.AspNetCore.Components.Forms.IBrowserFile]]'. at Microsoft.AspNetCore.Components.Reflection.PropertySetter.CallPropertySetter[TTarget,TValue](Action2 setter, Object target, Object value) at Microsoft.AspNetCore.Components.Reflection.ComponentProperties.g__SetProperty|3_0(Object target, PropertySetter writer, String parameterName, Object value) --- End of inner exception stack trace --- at Microsoft.AspNetCore.Components.Reflection.ComponentProperties.g__SetProperty|3_0(Object target, PropertySetter writer, String parameterName, Object value) at Microsoft.AspNetCore.Components.Reflection.ComponentProperties.SetProperties(ParameterView& parameters, Object target) at Microsoft.AspNetCore.Components.ComponentBase.SetParametersAsync(ParameterView parameters) at Microsoft.AspNetCore.Components.Rendering.ComponentState.SupplyCombinedParameters(ParameterView directAndCascadingParameters)

Any Ideas on why that might happen?

Thanks, Nadav.

yfbenkhalifa commented 6 months ago

Hi, I ran into the exact same issue, i temporarily solved by using this snippet which basically does the same thing: https://try.mudblazor.com/snippet/QYGcvPGRKNnbVkiE

nadavhury commented 6 months ago

Thank you for taking the time to address this, I wanted to have the entire component features, so I copied the entire component razor and razor.cs to a new component inside my project and it worked ok, No other changes needed.

yfbenkhalifa commented 6 months ago

Yeah that is basically, what I did as well, glad it worked out for you too!

mckaragoz commented 6 months ago

Do you have idea why it doesn't work? Is ButtonTemplate a new thing?

yfbenkhalifa commented 6 months ago

The error was: Unable to cast object of type 'Microsoft.AspNetCore.Components.RenderFragment1[System.String]' to type 'Microsoft.AspNetCore.Components.RenderFragment1[MudBlazor.FileUploadButtonTemplateContext`1[Microsoft.AspNetCore.Components.Forms.IBrowserFile]]'

I assume the problem is in the upload button for the csv

EFIDEMMS commented 6 months ago

I've got the same issue in WASM project. It seems an incompatibility with .net8. On .net7, csvmapper component works like a charm.

mckaragoz commented 5 months ago

New version (6.8.0) released and it natively supports .NET 8 could you try it again?

nadavhury commented 5 months ago

New version (6.8.0) released and it natively supports .NET 8 could you try it again?

I checked on the .net 8, 6.8.0 version and all is working ok.

michaelthwaite commented 2 months ago

I'm getting a similar issue as far as I can tell, in .net 8.0.204, I get an Unhandled Promise Rejection: Error: System.ArgumentNullException: ArgumentNull_Generic Arg_ParamName_Name, obj at System.ArgumentNullException.Throw(String paramName) at System.Reflection.CustomAttribute.GetCustomAttributes...

... At the moment that I drop the file to be processed.

FYI: CsvHelper: 31.0.3, extensions: 69.2

However, if I copy the component into my code and reference that, all is well.