I am making a 3D simulator in Unity.   

For this simulator I need some data which I store in a Serializable object.   

This object is defined in a DLL file that I made.  

I deserialize it with this code:

```
public class myObject
{
    static public myObject LoadFromFile(String Path)
    {
        System.Runtime.Serialization.Formatters.Binary.BinaryFormatter BF = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
        System.IO.FileStream FS = new System.IO.FileStream(Path, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
        myObject Result = BF.Deserialize(FS) as myObject;
        FS.Close();
        return Result;
    }
}

```

My unity program has a reference to the class library containing the definition of 'myObject'.   

If I run the deserialization function from Unity this process takes 35.080 seconds.

If I run this in a windows application, which I created for testing purpose and refers to the same class library and opens the same file, this process takes only 0.260 seconds.  

It takes a long time in Unity even if I run this process asynchronously.

I wonder why it takes that much longer when I run this code from Unity?
and if there is anything that I can do about this?

Thanks in advance,   

Maarten