Skip to content

Exception when calling MessagePackSerializer.Get<T> in SL5 #205

Closed

Description

@ericontilt

When calling MessagePackSerializer.Get in SL5 (where T is some complex object) I get the following exception

Attempt by method 'MsgPack.Serialization.ReflectionExtensions.CreateInstancePreservingExceptionType(System.Type, System.Object[])' to access method 'MsgPack.Serialization.DefaultSerializers.GenericSerializer+ListInstanceFactory`1<System.__Canon>..ctor()' failed.

I'm using version 0.8.0. Any pointer as to what this means?

My stack trace is:

at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at MsgPack.Serialization.ReflectionExtensions.CreateInstancePreservingExceptionType(Type type, Object[] constructorParameters)
at MsgPack.Serialization.DefaultSerializers.GenericSerializer.CreateListSerializer(SerializationContext context, Type itemType, PolymorphismSchema schema)
at MsgPack.Serialization.DefaultSerializers.GenericSerializer.Create(SerializationContext context, Type targetType, PolymorphismSchema schema)
at MsgPack.Serialization.DefaultSerializers.GenericSerializer.Create[T](SerializationContext context, PolymorphismSchema schema)
at MsgPack.Serialization.SerializationContext.GetSerializer[T](Object providerParameter)
at MsgPack.Serialization.SerializationContext.SerializerGetter1.Get(SerializationContext context, Object providerParameter) at MsgPack.Serialization.SerializationContext.SerializerGetter.Get(SerializationContext context, Type targetType, Object providerParameter) at MsgPack.Serialization.SerializationContext.GetSerializer(Type targetType, Object providerParameter) at MsgPack.Serialization.ReflectionSerializers.ReflectionSerializerHelper.GetMetadata(Type targetType, IList1 members, SerializationContext context, Func2[]& getters, Action2[]& setters, MemberInfo[]& memberInfos, DataMemberContract[]& contracts, MessagePackSerializer[]& serializers)
at MsgPack.Serialization.ReflectionSerializers.ReflectionObjectMessagePackSerializer1..ctor(SerializationContext context) at MsgPack.Serialization.MessagePackSerializer.CreateReflectionInternal[T](SerializationContext context, Type concreteType, PolymorphismSchema schema) at MsgPack.Serialization.MessagePackSerializer.CreateInternal[T](SerializationContext context, PolymorphismSchema schema) at MsgPack.Serialization.SerializationContext.GetSerializer[T](Object providerParameter) at MsgPack.Serialization.SerializationContext.SerializerGetter1.Get(SerializationContext context, Object providerParameter)
at MsgPack.Serialization.SerializationContext.SerializerGetter.Get(SerializationContext context, Type targetType, Object providerParameter)
at MsgPack.Serialization.SerializationContext.GetSerializer(Type targetType, Object providerParameter)
at MsgPack.Serialization.ReflectionSerializers.ReflectionSerializerHelper.GetMetadata(Type targetType, IList1 members, SerializationContext context, Func2[]& getters, Action2[]& setters, MemberInfo[]& memberInfos, DataMemberContract[]& contracts, MessagePackSerializer[]& serializers) at MsgPack.Serialization.ReflectionSerializers.ReflectionObjectMessagePackSerializer1..ctor(SerializationContext context)
at MsgPack.Serialization.MessagePackSerializer.CreateReflectionInternal[T](SerializationContext context, Type concreteType, PolymorphismSchema schema)
at MsgPack.Serialization.MessagePackSerializer.CreateInternal[T](SerializationContext context, PolymorphismSchema schema)
at MsgPack.Serialization.SerializationContext.GetSerializer[T](Object providerParameter)
at MsgPack.Serialization.MessagePackSerializer.Get[T](SerializationContext context, Object providerParameter)
at MsgPack.Serialization.MessagePackSerializer.Get[T](SerializationContext context)
at MsgPack.Serialization.MessagePackSerializer.GetT

Activity

  1. added
    bug
    on Dec 9, 2016
  2. yfakariya commented on Dec 9, 2016

    @yfakariya
    Member

    Thank you for reporting!
    Would you tell me about where did you run the problem? It might be related to code access security.

  3. ericontilt commented on Dec 10, 2016

    @ericontilt
    Author

    Sure. It's in the callback handler of a web request. What's interesting though, is that we have version 0.4 in production code and it works fine. I literally updated the package version and changed the line of invocation from .Create to .Get. That's it.

    By the way, I also tried with version 0.6, and I get a bit more detail with my exceptions. It first throws on one of my custom types (a custom Date class), but it will also throw on something like TimeSpan. Again, with no changes on the backend in the data class which worked fine with the older version.

  4. yfakariya commented on Dec 24, 2016

    @yfakariya
    Member

    Thank you for interesting information. I fixed a lot for Xamarin and Unity support in 0.5, it may affect something. I will investigate it.

  5. added a commit that references this issue on Jan 8, 2017
    8950e80
  6. yfakariya commented on Jan 9, 2017

    @yfakariya
    Member

    I confirmed that this issue is caused by code access security. I'm fixing this issue.

  7. ericontilt commented on Jan 9, 2017

    @ericontilt
    Author

    Ok, cool. Please let me know if there's anything I can do to help test it.

  8. added a commit that references this issue on Jan 29, 2017
    e9ff9af
  9. carldiegelmann commented on Feb 6, 2017

    @carldiegelmann

    When will this fix be available in any version? Also in 0.8.2? Thanks!

  10. yfakariya commented on Feb 6, 2017

    @yfakariya
    Member

    0.9.0. I'm fixing #202 now, and then I will release rc.

  11. added 2 commits that reference this issue on Feb 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions