public static TObjectType DeserializeFromByteArray <TObjectType>(IFormatter objFormatter, byte[] bytData) where TObjectType : ObjectBase { TObjectType objValue = default(TObjectType); if (bytData == null) { throw new ArgumentException("bytData", "A valid non-null byte[] is required."); } try { SerializedObject objSerializedObject = objFormatter.DeserializeFromByteArray(bytData); objValue = (TObjectType)objSerializedObject.Deserialize(); } catch (Exception objException) { throw new Exception("An error was encountered while attempting to load the string.", objException); } return(objValue); }