msgpack-cli icon indicating copy to clipboard operation
msgpack-cli copied to clipboard

Trouble with serialization / deserialization - unable to cast

Open DBalashov opened this issue 9 years ago • 1 comments

We use msgpack for store our classes to binary content (.NET 4.5, IIS 7.x). After some operations, error occured:

Unable to cast object of type 'MsgPack.Serialization.EmittingSerializers.Generated.AutoGRAPHCharts_ModIndSettingsSerializer405' to type 'MsgPack.Serialization.MessagePackSerializer`1[AutoGRAPHCharts.ModIndSettings]'.

Image

This class located in separated assembly, but assembly successfully loaded for other purposes and working fine. Currently, we use msgpack 0.7.2259.1047 (but I'm try to use release version 0.7.1 - nothing difference).

Error occured in MessagePackSerializer.Factories.cs:

return (MessagePackSerializer<T>) builder.BuildSerializerInstance(context, concreteType, schema == null ? null : schema.FilterSelf());

Related class (but I can't show completed hierarchy, because is very complex and deep):

public interface IAutoGRAPHSettings
    {
        string[] Descriptions { get; }
        Image Image { get; }
    }

public sealed class ModIndSettings : IAutoGRAPHSettings
    {
        string[] IAutoGRAPHSettings.Descriptions { get { return new[] { "Appearance|Charts appearance|color icons statuses" }; } }
        Image IAutoGRAPHSettings.Image { get { return null; } }

        public bool UseBackColor { get; set; }
        public int BackColor { get; set; }
        public bool ShowIcons { get; set; }
        public bool ShowStates { get; set; }
        public bool ShowScrollbar { get; set; }
        public bool AxisYFromZero { get; set; }
        public bool AggregatePoints { get; set; }

        public ModIndSettings()
        {
            UseBackColor = false;
            BackColor = Color.Black.ToArgb();
            ShowIcons = true;
            ShowStates = true;
            ShowScrollbar = false;

            AxisYFromZero = true;
            AggregatePoints = false;
        }
    }

DBalashov avatar Jul 14 '16 05:07 DBalashov

In simple case, this issue has not been reproduced. So, I guess ASP.NET issue was occurred namely assembly shadow copying related error. The ModIndSettingss become differ if the type is loaded from different location even if the assembly content is identical with previous loaded one. Do you think it is the case?

yfakariya avatar Jul 17 '16 08:07 yfakariya