uwp 周年更新二进制格式化程序

uwp anniversary update Binary formatter

我在面向 anniversary sdk 的 uwp 项目中找不到 Binary Formatter class。问题是我需要与一些在 3 个项目之间使用 Binary Formatter 的方法共享一个助手 class 1. webapi ( dotner 核心 3 ) 2. uwp主应用(1809 sdk) 3. uwp side app ( anniversary sdk )

现在二进制格式化程序在第一个和第二个项目中默认可用,但在第三个项目中它会导致编译错误。我基本上使用这个助手 class 进行加密。

代码

private byte[] ConvertIntoByte(object value)
{
    using (var ms = new MemoryStream())
    {
        var bf = new BinaryFormatter();
        bf.Serialize(ms, value ?? "null");
        return ms.ToArray();
    }
}

我不得不添加 "EcoCore" nuget,然后重新加载项目清理并重建解决了这个问题。

now the binary formatter is by default available in 1st 2 projects but in the third one it causes compile error.

问题是 BinaryFormatter class only applies to .Net Standard 2.0 2.1. It means that the minimum UWP support version is 16299. So please modify your side app target minimum version to 16299. Or install third-part lib such as EcoCore.