I have been trying out the GeoSerializer feature and it worked well for single layers however I tried to use it to serialize a GeoCollection of three InMemoryFeatureLayers and got the following error:
System.ArgumentException was unhandled
Message="Invalid name character in 'GeoCollection`1'. The '`' character, hexadecimal value 0x60, 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.WriteStartElement(String localName)
at ThinkGeo.MapSuite.Core.XmlGeoSerializationFormatter.4xU=(GeoObjectNode 5BU=, XmlWriter 5RU=)
at ThinkGeo.MapSuite.Core.XmlGeoSerializationFormatter.SaveCore(GeoObjectModel model, Stream stream)
at ThinkGeo.MapSuite.Core.GeoSerializationFormatter.Save(GeoObjectModel model, Stream stream)
at ThinkGeo.MapSuite.Core.GeoSerializer.Serialize(Object objectToSerialize, String targetPathFileName)
at PTSimpleMapper.clsMapSupport.mergeRedline(WinformsMap& theMap) in C:\Users\Jonathan\Documents\Visual Studio 2008\Projects\simpleMapper\simpleMapper\clsMapSupport.cs:line 623
at PTSimpleMapper.frmMap.mergeRedLines() in C:\Users\Jonathan\Documents\Visual Studio 2008\Projects\simpleMapper\simpleMapper\frmMap.cs:line 543
at PTSimpleMapper.ctrlRedline.btnMerge_Click(Object sender, EventArgs e) in C:\Users\Jonathan\Documents\Visual Studio 2008\Projects\simpleMapper\simpleMapper\ctrlRedline.cs:line 61
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(Int32 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(Form mainForm)
at PTSimpleMapper.Program.Main() in C:\Users\Jonathan\Documents\Visual Studio 2008\Projects\simpleMapper\simpleMapper\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(Assembly 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)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
My code is:
GeoSerializer redLineSerial = new GeoSerializer();
GeoCollection<InMemoryFeatureLayer> annotationLayers = new GeoCollection<InMemoryFeatureLayer>();
LayerOverlay emphasisOverlay = (LayerOverlay)theMap.Overlays[EMPHASIS_OVERLAY_NAME];
annotationLayers.Add((InMemoryFeatureLayer)emphasisOverlay.Layers[HIGHLIGHT_LAYER_NAME]);
annotationLayers.Add((InMemoryFeatureLayer)emphasisOverlay.Layers[REDLINE_LAYER_NAME]);
annotationLayers.Add((InMemoryFeatureLayer)emphasisOverlay.Layers[ANNOTATION_LAYER_NAME]);
redLineSerial.Serialize(annotationLayers, @"C:\ProgramData\Pear Technology\newMapper\redLineLayer.xml");
Am I doing something wrong or is serialization not intended to work that way?
Thanks,
Jonathan