Guys,
I have been using .NET binary serialization to save/restore the state of the map. This approach works great until we download a new set of dll's from the daily build and some change in one of the classes causes existing files no longer to load because of compatibility issues in the newer version.
Since ThinkGeo has now released the GeoSerializer (which is supposed to solve the compatibilty issue) I would like to switch to that method. However, if I try to serialize more than one layer to the file I receive an error when trying to deserialize:
System.Xml.XmlException was unhandled
LineNumber=122
LinePosition=27
Message=Unexpected XML declaration. The XML declaration must be the first node in the document, and no white space characters are allowed to appear before it. Line 122, position 27.
Source=System.Xml
SourceUri=""
StackTrace:
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParsePI(StringBuilder piInDtdStringBuilder)
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at ThinkGeo.MapSuite.Core.XmlGeoSerializationFormatter.xBQ=(XmlReader 4RU=)
at ThinkGeo.MapSuite.Core.XmlGeoSerializationFormatter.LoadCore(Stream stream)
at ThinkGeo.MapSuite.Core.GeoSerializationFormatter.Load(Stream stream)
at ThinkGeo.MapSuite.Core.GeoSerializer.Deserialize(Stream sourceStream)
at SerializeProjectedLayer.Form1.DeSerializeShapefile() in C:\Users\steller\Documents\Visual Studio 2010\Projects\ThinkGeo\SerializeProjectedLayer\Form1.vb:line 99
at SerializeProjectedLayer.Form1.btnDeserialize_Click(Object sender, EventArgs e) in C:\Users\steller\Documents\Visual Studio 2010\Projects\ThinkGeo\SerializeProjectedLayer\Form1.vb:line 165
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.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 Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at SerializeProjectedLayer.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.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
I have attached a sample project so you can see exactly what my code is doing. What can I do to fix this?
Thanks,
Steve
SerializeShapefiles.zip (27.6 KB)