C# 使用C反序列化带有kinect主体类的文件时出现异常

C# 使用C反序列化带有kinect主体类的文件时出现异常,c#,exception,serialization,kinect,binaryfiles,C#,Exception,Serialization,Kinect,Binaryfiles,我想保存在一个二进制文件,所以在使用它的身体。 我在不同的文件中序列化了每个体向量是否可以保存在同一个文件中?但当我反序列化它时,我有一个例外: Eccezione non gestita di tipo 'System.NullReferenceException' in ConsoleApplication6.exe Ulteriori informazioni: Riferimento a un oggetto non impostato su un'istanza di oggetto.

我想保存在一个二进制文件,所以在使用它的身体。 我在不同的文件中序列化了每个体向量是否可以保存在同一个文件中?但当我反序列化它时,我有一个例外:

Eccezione non gestita di tipo 'System.NullReferenceException' in ConsoleApplication6.exe
Ulteriori informazioni: Riferimento a un oggetto non impostato su un'istanza di oggetto.
对于调试,我有以下异常详细信息:

{"Fine del flusso raggiunta prima del termine dell'analisi."}   System.Exception {System.Runtime.Serialization.SerializationException}
这是我的代码:

public static void serialize(Body[] bodySerialized,String path)
        {
            Stream stream=null;
            try
            {
                BinaryFormatter bFormatter = new BinaryFormatter();
                stream = new FileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.None);
                bFormatter.Serialize(stream, bodySerialized);
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            finally
            {
                if (stream != null)
                    stream.Close();

            }
        }
public static Body[] deserialize(String path)
        {
            Body[] bodyDeserialized = null;
            Stream stream = null;

            try
            {
                BinaryFormatter bFormatter = new BinaryFormatter();
                stream = File.Open(path, FileMode.Open);
                bodyDeserialized = (Body[])bFormatter.Deserialize(stream);

            }catch(Exception ex)
            {
                ex.ToString();
            }
            if (stream != null)
                stream.Close();
            Console.WriteLine(bodyDeserialized.Length);
            return bodyDeserialized;
        }

错误在哪里?谢谢,SDK 2.0中的正文不可序列化。我使用了一个包装器可序列化类,现在运行正常了

您可以链接您使用的可序列化类吗?