I am running into an InvalidCastException when using a class with a property of type GUID. I believe that the at Syncfusion.EJ2.Blazor.BaseComponent.ChangeType method has problems converting a string value into a GUID object.
System.InvalidCastException: Invalid cast from 'System.String' to 'System.Guid'.
at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)
at System.String.System.IConvertible.ToType(Type type, IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType)
at Syncfusion.EJ2.Blazor.BaseComponent.ChangeType(Object value, Type conversionType)
at Syncfusion.EJ2.Blazor.BaseComponent.GetObject(Dictionary`2 Data, Type ModelType)
at Syncfusion.EJ2.Blazor.Grids.GridColumn.BuildRenderTree(RenderTreeBuilder builder)
at Microsoft.AspNetCore.Components.ComponentBase.<.ctor>b__5_0(RenderTreeBuilder builder)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment)
at Microsoft.AspNetCore.Components.Rendering.Renderer.RenderInExistingBatch(RenderQueueEntry renderQueueEntry)
And within my DynamicEntity class there exists a property of type Guid. As Guid does not implement the IConvertible interface, I think here lies the problem.
Is there some kind of possibility to attach a convertor to the Grid ? The only other solution for this problem which comes to my mind would be to implement something like a custom ConvertibleGuid-Type which does implement IConvertible.
RSRenjith Singh Rajendran Syncfusion Team July 30, 2019 08:31 AM
We have validated the defect you have initiated with us. Thank you for taking the time to report this issue “Script error : Invalid cast from 'System.String' to 'System.Guid'.” and helping us improve our product. At Syncfusion, we are committed to fixing all validated defects (subject to technological feasibility and Product Development Life Cycle ) and including the defect fix in our subsequent Nuget release which is expected to be roll out on or before August 19th 2019.
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.
thank you for your reply. I am looking forward for the next release. Would it be possible for me to fix this issue in the meantime by creating my own CustomGridColumn, which does derive from the Syncfusion.EJ2.Blazor.Grids.GridColumn? This class would then simply have its own ChangeType Method, which does some own conversion logic if the type happens to be a Guid. Otherwise it would call the method of the base class.
VNVignesh Natarajan Syncfusion Team July 31, 2019 06:28 AM
Thanks for your update.
Query: “Would it be possible for me to fix this issue in the meantime by creating my own CustomGridColumn, which does derive from the Syncfusion.EJ2.Blazor.Grids.GridColumn?”
No. Because we have used Blazor’s renderFragment concept to render the templates in Blazor Grid. So while using this concept, we will serialize the model class during the rendering which will contain the GUID property and exception will occur at that time itself even if we extend and use CustomGridColumn. Hence it is not feasible to achieve through any workaround. So we appreciate your patience until then.
We will get back to you once the reported issue is fixed.