neuecc / Utf8Json

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

Could not load file or assembly … The system cannot find the file specified #208

Closed yoav-melamed closed 4 years ago

yoav-melamed commented 4 years ago

Hi Guys, I've created a new console app in dotnet-core 3.1 Added utf8json (Install-Package Utf8Json) - v1.3.7 Write a simple code (taken for the docs):

public static void Main(string[] args)
{
    var p = new TestObj { parameter = "value" };

    // Object -> byte[] (UTF8)
    byte[] result = JsonSerializer.Serialize(p);

    // byte[] -> Object
    var p2 = JsonSerializer.Deserialize<TestObj>(result);

    // Object -> String
    var json = JsonSerializer.ToJsonString(p2);

    Console.ReadKey();
}

My TestObj class:

class TestObj
{
    public string parameter { get; set; }
}

When I'm running the app, I'm getting the following:

Unhandled exception. System.TypeLoadException: Type 'Utf8Json.Formatters.mongodb_tester_TestObjFormatter1' from assembly 'Utf8Json.Resolvers.DynamicObjectResolverAllowPrivateFalseExcludeNullFalseNameMutateOriginal, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is attempting to implement an inaccessible interface.
   at Utf8Json.JsonFormatterResolverExtensions.GetFormatterWithVerify[T](IJsonFormatterResolver resolver)
   at Utf8Json.JsonSerializer.Serialize[T](T value, IJsonFormatterResolver resolver)
   at Utf8Json.JsonSerializer.Serialize[T](T obj)

The Utf8Json.dll exist in 'bin\Debug\netcoreapp3.1' folder

Any idea what could it be?

yoav-melamed commented 4 years ago

Sorry guys Found the issue - TestObj class should be public