Skip to content

cannot serialize internal class? #3

@itn3000

Description

@itn3000

Environment

MessagePack assembly version is 1.0.1

here is dotnet --info output

.NET Command Line Tools (1.0.1)

Product Information:
 Version:            1.0.1
 Commit SHA-1 hash:  005db40cd1

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  16.04
 OS Platform: Linux
 RID:         ubuntu.16.04-x64
 Base Path:   /usr/share/dotnet/sdk/1.0.1

Steps to reproduce

compile the following source and run with dotnet run

using System;

namespace msgpack_cli_test
{
    using MessagePack;
    // if this class is public struct, success
    [MessagePackObject]
    struct TestObject
    {
        [Key(0)]
        public int A{get;set;}
        [Key(1)]
        public string B{get;set;}
    }
    class Program
    {
        static void Main(string[] args)
        {
            var obj  = new TestObject()
            {
                A = 100,
                B = "piyopiyo"
            };
            var data = MessagePackSerializer.Serialize(obj);
            Console.WriteLine($"{data.Length}");
            var x = MessagePackSerializer.Deserialize<TestObject>(data);
            Console.WriteLine($"{x.A}");
        }
    }
}

Expected Behavior

output two digits then exit 0

Actual Behavior

output following exception message

Unhandled Exception: System.TypeLoadException: Type 'MessagePack.Formatters.msgpack_cli_test_TestObjectFormatter' from assembly 'MessagePack.Resolvers.DynamicObjectResolver, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is attempting to implement an inaccessible interface.
   at MessagePack.FormatterResolverExtensions.GetFormatterWithVerify[T](IFormatterResolver resolver)
   at MessagePack.MessagePackSerializer.Serialize[T](T obj, IFormatterResolver resolver)
   at msgpack_cli_test.Program.Main(String[] args) in /home/malion/src/msgpack-cli-test/Program.cs:line 23

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions