Utf8Json icon indicating copy to clipboard operation
Utf8Json copied to clipboard

System.TypeLoadException: attempting to implement an inaccessible interface

Open maurosampietro opened this issue 4 years ago • 0 comments

I'm trying to parse a very simple json

   string json = @"{
                  ""Email"": ""[email protected]"",
                  ""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?

maurosampietro avatar Feb 11 '21 11:02 maurosampietro