Load Binary Formatter file in Universal app

2019-09-02 14:55发布

问题:

I have an application build with .NET 4.0 and I want to port this application to a Windows 10 application.

In the old application I saved my data to a binary file using Binary Formatter.

using (FileStream fs2 = File.Create(serializationFile))
            {
                var bformatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();

                bformatter.Serialize(fs2, transactionData);
            }

With the following class that is serialized:

    [Serializable]
public class TransactionData
{
    public TransactionData()
    {

    }

    public string Name { get; set; }
    public List<TransactionCategory> TransactionCategories { get; set; }
    public List<TransactionMonth> TransactionMonths { get; set; }
}

I would like to load that files in my Universal App.

The problem is the following are not working:

[Serializable]

and:

System.Runtime.Serialization.Formatters

Is it possible to load this files in Universal App? And if so, how can it be done?