Skip to content
This repository has been archived by the owner on May 16, 2022. It is now read-only.

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

Open
maurosampietro opened this issue Feb 11, 2021 · 0 comments

Comments

@maurosampietro
Copy link

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant