Hi,
I have been looking forward to being able to use the new GeoSerializer class. We currently serialize maps to a binary format and every time we move to a newer build of MS Desktop none of our files will open anymore.
I tried the GeoSerializer but I get an error every time:
System.ArgumentException was unhandled
Message=Invalid name character in 'fRU='. The '=' character, hexadecimal value 0x3D, cannot be included in a name.
Source=System.Xml
StackTrace:
at System.Xml.XmlWellFormedWriter.CheckNCName(String ncname)
at System.Xml.XmlWellFormedWriter.WriteStartElement(String prefix, String localName, String ns)
at System.Xml.XmlWriter.WriteElementString(String localName, String ns, String value)
at System.Xml.XmlWriter.WriteElementString(String localName, String value)
at ThinkGeo.MapSuite.Core.XmlSerializationFormatter.jDU=(GeoSerializationNode jTU=, XmlWriter jjU=)
at ThinkGeo.MapSuite.Core.XmlSerializationFormatter.jDU=(GeoSerializationNode jTU=, XmlWriter jjU=)
at ThinkGeo.MapSuite.Core.XmlSerializationFormatter.SaveCore(GeoSerializationNode node, Stream stream)
at ThinkGeo.MapSuite.Core.GeoSerializationFormatter.Save(GeoSerializationNode node, Stream stream)
at ThinkGeo.MapSuite.Core.GeoSerializer.Serialize(Object serializationObject)
at SerializeProjectedLayer.Form1.SerializeShapefile() in C:\Users\steller\Documents\Visual Studio 2010\Projects\ThinkGeo\SerializeProjectedLayer\Form1.vb:line 58
at SerializeProjectedLayer.Form1.btnSerialize_Click(Object sender, EventArgs e) in C:\Users\steller\Documents\Visual Studio 2010\Projects\ThinkGeo\SerializeProjectedLayer\Form1.vb:line 117
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()
InnerException:
Here is the code that does attempts to serialize the layer:
Private Sub SerializeShapefile()
Dim oGeoSerializer As New GeoSerializer
Dim oStream As FileStream
Dim sFileName As String
Dim oOverlay As LayerOverlay
sFileName = GetUserFolder() & "Shapefile.wxd"
'***** Open a file stream to use for serialization
oStream = New FileStream(sFileName, FileMode.Create, FileAccess.Write, FileShare.None)
oOverlay = CType(WinformsMap1.Overlays(0), LayerOverlay)
If oOverlay.Layers(0).IsOpen Then
oOverlay.Layers(0).Close()
End If
oGeoSerializer.Serialize(oOverlay.Layers(0))
oStream.Close()
End Sub
We are using build 5.5.24.0. I have attached a sample project to make it easy to reproduce.
Thanks!
Steve
SerializeProjectedLayer.zip (317 KB)