Hi, All,

Good day!

I would like to ask for help on how to solve below error:

Exception: The ObjectManager found an invalid number of fixups. This usually indicates a problem in the Formatter.

This is the piece of code where the error occurred:

 Private Function DeSerializeObject(ByVal PathFile As String) As Object
            Using FileStream As IO.Stream = New IO.FileStream(PathFile, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
                Dim formatter As Runtime.Serialization.IFormatter = New Runtime.Serialization.Formatters.Binary.BinaryFormatter
                Me.Question = DirectCast(formatter.Deserialize(FileStream), UI.Tools.QuestionCollections)
                Return Me.Question
            End Using
        End Function

What should I do. I ran out of options. Thank you in advance for help.

Here's the stack trace:

at System.Runtime.Serialization.ObjectManager.DoFixups()
   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 System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
   at MagnaToolsLib.CodeBookLibrary.Tools.ImportExportCodeBook.DeSerializeObject(String PathFile) in D:\1052\law\OLD\SPi Survey System\SPiSurveySystem\CodebookLibrary\Tools\ImportExportCodeBook.vb:line 52
   at MagnaToolsLib.CodeBookLibrary.Tools.ImportExportCodeBook.Import(String CodeBookFile) in D:\1052\law\OLD\SPi Survey System\SPiSurveySystem\CodebookLibrary\Tools\ImportExportCodeBook.vb:line 46
   at MagnaToolsLib.CodeBookLibrary.Processes.Inventory.LoadNewJobname() in D:\1052\law\OLD\SPi Survey System\SPiSurveySystem\CodebookLibrary\Processes\Inventory\Inventory.vb:line 691
   at MagnaToolsLib.CodeBookLibrary.Processes.Inventory.btnNewJob_Click(Object sender, EventArgs e) in D:\1052\law\OLD\SPi Survey System\SPiSurveySystem\CodebookLibrary\Processes\Inventory\Inventory.vb:line 678
   at DevComponents.DotNetBar.BaseItem.RaiseClick(eEventSource source)
   at DevComponents.DotNetBar.BaseItem.InternalMouseUp(MouseEventArgs objArg)
   at DevComponents.DotNetBar.PopupItem.InternalMouseUp(MouseEventArgs objArg)
   at DevComponents.DotNetBar.ButtonItem.InternalMouseUp(MouseEventArgs objArg)
   at DevComponents.DotNetBar.BaseItem.InternalMouseUp(MouseEventArgs objArg)
   at DevComponents.DotNetBar.GenericItemContainer.InternalMouseUp(MouseEventArgs objArg)
   at DevComponents.DotNetBar.Bar.OnMouseUp(MouseEventArgs e)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at DevComponents.DotNetBar.Bar.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.RunDialog(Form form)
   at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
   at SPiSurveySystem.StartMenuControl.ExecuteDialogApps_Executed(Object sender, EventArgs e) in D:\1052\law\OLD\SPi Survey System\SPiSurveySystem\SPiSurveySystem\UserControl\StartMenuControl.vb:line 734
   at DevComponents.DotNetBar.Command.OnExecuted(ICommandSource commandSource, EventArgs e)
   at DevComponents.DotNetBar.Command.Execute(ICommandSource commandSource)
   at DevComponents.DotNetBar.CommandManager.ૂ(ICommandSource ૃ)
   at DevComponents.DotNetBar.BaseItem.ExecuteCommand()
   at DevComponents.DotNetBar.Metro.MetroTileItem.OnClick()
   at DevComponents.DotNetBar.BaseItem.RaiseClick(eEventSource source)
   at DevComponents.DotNetBar.BaseItem.InternalMouseUp(MouseEventArgs objArg)
   at DevComponents.DotNetBar.Metro.MetroTileItem.InternalMouseUp(MouseEventArgs objArg)
   at DevComponents.DotNetBar.BaseItem.InternalMouseUp(MouseEventArgs objArg)
   at DevComponents.DotNetBar.ItemContainer.InternalMouseUp(MouseEventArgs objArg)
   at DevComponents.DotNetBar.ItemControl.OnMouseUp(MouseEventArgs e)
   at DevComponents.DotNetBar.ItemPanel.OnMouseUp(MouseEventArgs e)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at DevComponents.DotNetBar.ItemControl.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(ApplicationContext context)
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
   at SPiSurveySystem.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
   at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
   at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
   at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
   at System.Activator.CreateInstance(ActivationContext activationContext)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Your help will be much appreciated.

I really need your input guys. Please do help me.

google says that I need to create a custom SerializationBinder. Below is the code that I've added:

I just don't understand the string that should be replaced and what is the string replacement.

Class Binder
        Inherits SerializationBinder
        Public Overrides Function BindToType(assemblyName As String, typeName As String) As Type
            typeName = typeName.Replace("what_to_put_here?", "what_to_put_here?")
            Return Type.[GetType](typeName)
        End Function
        'method
    End Class

Not yet solve. :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.