I am trying to migrate WPF application to .NET core . In my project serialization is used heavily. Below function work well on .NET 4.7 framework but after migrating to .NET