C1Flex "SerializationException" when appyling theme and style has DataMap

Posted by: wknauf on 23 March 2024, 10:20 pm EST

  • Posted 23 March 2024, 10:20 pm EST

    This seems to be caused by the change for fixing https://developer.mescius.com/forums/winforms-edition/applying-theme-to-c1flexgrid-resets-cellstyle-datamap - now “CellStyle.BuildString” tries to serialize a DataMap. But in my sample, the datamap items are not serializable.

    This causes a crash with .643 - see attached sample FlexColDataType.zip:

    System.Reflection.TargetInvocationException
      HResult=0x80131604
      Message=Exception has been thrown by the target of an invocation.
      Source=System.Private.CoreLib
      StackTrace:
       at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) in /_/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs:line 435
      This exception was originally thrown at this call stack:
        System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(System.Type) in FormatterServices.cs
        System.Runtime.Serialization.FormatterServices.GetSerializableMembers.AnonymousMethod__5_0(System.Runtime.Serialization.MemberHolder) in FormatterServices.cs
        System.Collections.Concurrent.ConcurrentDictionary<TKey, TValue>.GetOrAdd(TKey, System.Func<TKey, TValue>)
        System.Runtime.Serialization.FormatterServices.GetSerializableMembers(System.Type, System.Runtime.Serialization.StreamingContext) in FormatterServices.cs
        System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo() in WriteObjectInfo.cs
        System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(object, System.Runtime.Serialization.ISurrogateSelector, System.Runtime.Serialization.StreamingContext, System.Runtime.Serialization.Formatters.Binary.SerObjectInfoInit, System.Runtime.Serialization.IFormatterConverter, System.Runtime.Serialization.Formatters.Binary.ObjectWriter, System.Runtime.Serialization.SerializationBinder) in WriteObjectInfo.cs
        System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo, System.Runtime.Serialization.Formatters.Binary.NameInfo, System.Runtime.Serialization.Formatters.Binary.NameInfo) in ObjectWriter.cs
        System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteArrayMember(System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo, System.Runtime.Serialization.Formatters.Binary.NameInfo, object) in ObjectWriter.cs
        System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteArray(System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo, System.Runtime.Serialization.Formatters.Binary.NameInfo, System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo) in ObjectWriter.cs
        System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo, System.Runtime.Serialization.Formatters.Binary.NameInfo, System.Runtime.Serialization.Formatters.Binary.NameInfo) in ObjectWriter.cs
        ...
        [Call Stack Truncated]
    Inner Exception 1:
    SerializationException: Type 'FlexColDataType.MyData' in Assembly 'FlexColDataType, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.
    

    Making our DataMap data serializable is not really an option…

    My suggestion would be to store the DataMap content in some variable in C1FlexGrid.ThemeChanged and restore if afterwards instead of relying on the style string.

    And my own workaround will be to reset the datamap before applying a theme.

    Best regards

    Wolfgang

  • Posted 25 March 2024, 6:55 pm EST

    Hi Wolfgang,

    Thank you for sharing all the details. We have escalated the issue to the development team to get their insights on this and will let you know as soon as possible.

    [Internal Tracking ID: C1WIN-31881]

    Best Regards,

    Kartik

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels