Invalid Serialized File Header Unity

Posted on

Physics: Physics Meshes are now rejected if they contain invalid (non-finite) vertices. Playables: Refactored API so that Playables are structs instead of classes, making the API allocation-less in C#. Scripting: Added two new script errors in the editor for catching calls to the Unity API during serialization.

Active6 years, 4 months ago
Invalid Serialized File Header Unity

Suppose you have some AppendObjectOutputStream class (which is an ObjectOutputStream!) which overrides writeStreamHeader() like this:

Now also, let's say you plan on saving multiple objects to a file; one object for each time your program runs. Would you, even on the first run, use AppendObjectOutputStream()?

Driver

Mike WarrenMike Warren
1,5222 gold badges18 silver badges46 bronze badges

1 Answer

You have to write the stream header first time with regular ObjectOutputStream otherwise you will get java.io.StreamCorruptedException on opening the file with ObjectInputStream.

Evgeniy DorofeevEvgeniy Dorofeev
110k24 gold badges160 silver badges227 bronze badges
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.

Unity 5.1 Invalid Serialized File Header

Not the answer you're looking for? Browse other questions tagged javaobjectserialization or ask your own question.

Sage Act 2011 Problem

I have Sage Act 2011 Quit working yesterday and gave me this message

Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = 'Act.UI.ActApplication', name = '. Exception message is: The current build operation (build key Build Key[Act.UI.ActApplication, null]) failed: System.Runtime.Serialization.SerializationException: Binary stream '0' does not contain a valid BinaryHeader. Possible causes are invalid stream or object version change between serialization and deserialization.
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at Act.UI.Core.CustomCommandHelper.Deserialize(String fileName) (Strategy type BuildPlanStrategy, index 3) ---> Microsoft.Practices.ObjectBuilder2.BuildFailedException: The current build operation (build key Build Key[Act.UI.ActApplication, null]) failed: System.Runtime.Serialization.SerializationException: Binary stream '0' does not contain a valid BinaryHeader. Possible causes are invalid stream or object version change between serialization and deserialization.
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at Act.UI.Core.CustomCommandHelper.Deserialize(String fileName) (Strategy type BuildPlanStrategy, index 3) ---> System.Exception: System.Runtime.Serialization.SerializationException: Binary stream '0' does not contain a valid BinaryHeader. Possible causes are invalid stream or object version change between serialization and deserialization.
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at Act.UI.Core.CustomCommandHelper.Deserialize(String fileName)
at Act.UI.Core.CustomCommandHelper.Deserialize(String fileName)
at Act.UI.Core.CustomCommandHelper.get_CustomMacroHandlers()
at Act.UI.Core.Explorer.RestoreImagesToCollection()
at Act.UI.Core.Explorer.LoadDisconnectedMenuToolBar()
at Act.UI.ActApplication.InitializeExplorer()
at Act.UI.ActApplication.InitializeApplication()
at Act.UI.ActApplication.ctor(IUnityContainer container, IEventAggregator eventAggregator)
at BuildUp_Act.UI.ActApplication(IBuilderContext )
at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
--- End of inner exception stack trace ---
at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.Builder.BuildUp(IReadWriteLocator locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain strategies, Object buildKey, Object existing)
at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name)
--- End of inner exception stack trace ---
at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name)
at Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name)
at Microsoft.Practices.Unity.UnityContainerBase.Resolve[T]()
at Act.Application.ActBootstrapper.ConfigureContainer()
at Act.Composite.UnityExtensions.SimpleUnityBootstrapper.Run(Boolean useDefaultConfiguration)
at Act.Application.Act.Main(String[] args)