neuecc / Utf8Json

Definitely Fastest and Zero Allocation JSON Serializer for C#(NET, .NET Core, Unity, Xamarin).
MIT License
2.36k stars 267 forks source link

System.TypeLoadException: attempting to implement an inaccessible interface #246

Open maurosampietro opened 3 years ago

maurosampietro commented 3 years ago

I'm trying to parse a very simple json

   string json = @"{
                  ""Email"": ""mauro.sampietro@gmail.com"",
                  ""Active"": ""true"",
                  ""CreatedDate"": ""2013-01-20T00:00:00Z"",
                  ""Roles"": 
                    [
                        ""User"",
                        ""Admin""
                    ]
                }";

    public class Item
    {
        public string id { get; set; }
        public string ppu { get; set; }
        public Batters batters { get; set; }
        public Ingredient[] toppings { get; set; }
    }

    public class Batters
    {
        public List<Ingredient> batter { get; set; }
    }

    public class Ingredient
    {
        public string id { get; set; }
        public string type { get; set; }
    }

    static void Main(string[] args)
    {     
        var item = JsonSerializer.Deserialize<Item>( json );  
     }

I get System.TypeLoadException: 'Type 'Utf8Json.Formatters.Program+ItemFormatter1' from assembly 'Utf8Json.Resolvers.DynamicObjectResolverAllowPrivateFalseExcludeNullFalseNameMutateOriginal, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is attempting to implement an inaccessible interface.'

I'm executing this in the 'PerfBenchmark' project provided with the sourcecode to avoid any possible misconfiguration. What's the problem?