ThinkGeo.com    |     Documentation    |     Premium Support

Unable to serialize MapPrinterLayer with latest stable build

Hello again!

Recently we upgraded to MS 10 Desktop and we are currently using the latest stable builds for all TG components. But now when I try to use GeoSerializer to serialize the MapPrinterLayer I get the following exception:

System.ArgumentException was unhandled
  HResult=-2147024809
  Message=Invalid name character in '7hU='. The '7' character, hexadecimal value 0x37, 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 ThinkGeo.MapSuite.Serialize.XmlGeoSerializationFormatter.eSQ=(GeoObjectNode node, XmlWriter xmlWriter)
       at ThinkGeo.MapSuite.Serialize.XmlGeoSerializationFormatter.eSQ=(GeoObjectNode node, XmlWriter xmlWriter)
       at ThinkGeo.MapSuite.Serialize.XmlGeoSerializationFormatter.eSQ=(GeoObjectNode node, XmlWriter xmlWriter)
       at ThinkGeo.MapSuite.Serialize.XmlGeoSerializationFormatter.SaveCore(GeoObjectModel model, Stream stream)
       at ThinkGeo.MapSuite.Serialize.GeoSerializer.Serialize(Object objectToSerialize, String targetPathFilename)
       at Serialization_Bug.Form1.Form1_Load(Object sender, EventArgs e) in C:\Users\ZipPa\Documents\Visual Studio 2015\Projects\Serialization Bug\Form1.vb:line 30
       at System.EventHandler.Invoke(Object sender, EventArgs e)
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.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)
  InnerException: 

In putting together a sample I could not reproduce the problem until I got a private property, mapImageCache, to populate on the MapPrinterLayer. It appears that this is the property that causes the issue. Please have a look and see if there is some workaround.

Serialization Bug.zip (51.9 KB)

Thanks!

Steve

Hi Steve,

Thanks to let us know that.

That should be a bug, you can get that in this version:


or

Regards,

Ethan

Ethan,

Thanks for the quick response. Serialization of MapPrinterLayer works without error. However, now there is an exception when trying to deserialize MapPrinterLayer. I have identified the problem in the xml created when MapPrinterLayer is serialized. It seems to be related to the earlier issue. This is only a problem when the application is running as a 64 bit process. Here is the problem xml:

      <mapImageCache>
        <nativeImage inherit="true" type="System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
          <nativeImage>136862936</nativeImage>
        </nativeImage>
          <mapImageCache>
    <nativeImage inherit="true" type="System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
      <nativeImage>2280503954080</nativeImage>
    </nativeImage>
    <imageBytes>iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAAA1JREFUGFdjYGBgYAAAAAUAAYoz4wAAAAAASUVORK5CYII=</imageBytes>
  </mapImageCache>

The native image tag <nativeImage>2280503954080</nativeImage> is the cause of the exception:

System.OverflowException was unhandled
  HResult=-2146233066
  Message=Value was either too large or too small for an Int32.
  Source=mscorlib
  StackTrace:
       at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
       at System.Convert.ToInt32(String value)
       at ThinkGeo.MapSuite.Serialize.GeoObjectModeler.WyQ=(Type type, String value)
       at ThinkGeo.MapSuite.Serialize.GeoObjectModeler.CreateMemberObject(String memberName, Type memberType, Object memberOwner, GeoObjectNode memberNode)
       at ThinkGeo.MapSuite.Serialize.GeoObjectModeler.WiQ=(GeoObjectNode node, Object result)
       at ThinkGeo.MapSuite.Serialize.GeoObjectModeler.VSQ=(GeoObjectNode node, String typeName)
       at ThinkGeo.MapSuite.Serialize.GeoObjectModeler.CreateMemberObject(String memberName, Type memberType, Object memberOwner, GeoObjectNode memberNode)
       at ThinkGeo.MapSuite.Serialize.GeoObjectModeler.WiQ=(GeoObjectNode node, Object result)
       at ThinkGeo.MapSuite.Serialize.GeoObjectModeler.VSQ=(GeoObjectNode node, String typeName)
       at ThinkGeo.MapSuite.Serialize.GeoObjectModeler.CreateMemberObject(String memberName, Type memberType, Object memberOwner, GeoObjectNode memberNode)
       at ThinkGeo.MapSuite.Serialize.GeoObjectModeler.WiQ=(GeoObjectNode node, Object result)
       at ThinkGeo.MapSuite.Serialize.GeoObjectModeler.VSQ=(GeoObjectNode node, String typeName)
       at ThinkGeo.MapSuite.Serialize.GeoSerializer.Deserialize(String sourcePathFilename, GeoFileReadWriteMode readWriteMode)
       at Serialization_Bug.Form1.mSerialize() in C:\Users\ZipPa\Documents\Visual Studio 2015\Projects\Serialization Bug\Form1.vb:line 39
       at Serialization_Bug.Form1.Form1_Load(Object sender, EventArgs e) in C:\Users\ZipPa\Documents\Visual Studio 2015\Projects\Serialization Bug\Form1.vb:line 19
       at System.EventHandler.Invoke(Object sender, EventArgs e)
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  InnerException: 

Again, only a problem when the program is compiled so that it runs as a 64 bit process. It has taken me all day to figure out that the 64-bit issue was causing the problem. I have modified my sample project to reproduce this issue and here it is.
Serialization Bug_2.zip (77.7 KB)

Please have a try and see what happens.

Thanks!

Steve

Hi Steve,

Thanks for your sample, that’s helpful to let us start work for it.

Our developer had fixed that, please get the


or

Regards,

Ethan

Hi Ethan,

Thanks again for a quick response. Now I can deserialize MapPrinterLayer in the sample project without a problem. However, now there is a problem after the MapPrinterLayer is deserialized. I have made a change to the sample project so you can see the problem.

Run the project. You will see a form with a map that has a
PrinterInteractiveOverlay which contains a PagePrinterLayer and a
MapPrinterLayer, After the form displays you can zoom and pan the
map and all is well.

Now, click the ‘Serialize’ button. The MapPrinterLayer will be serialized, then deserialized. However the deserialized MapPrinterLayer is not used in the PrinterInteractiveOverlay.

Zoom and Pan the map and you will receive the following exception:

System.Runtime.InteropServices.SEHException was unhandled
Message: An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in System.Drawing.dll
Additional information: External component has thrown an exception.

No stack trace so it’s difficult to find out the problem.

Can you help? Here is the latest sample project:
Serialization Bug_3.zip (78.5 KB)

Thanks again!

Steve

Hi Steve,

Thanks for your detail description and your sample, that’s very helpful.

We fixed that in https://www.nuget.org/packages/ThinkGeo.MapSuite.Layers.Printers/11.0.0-beta008 package, it will be updated later today. This fix works for the scenario of your sample, please try it and let us know if you met any problem.

Regards,

Ethan

Ethan,

Thanks! I tested with the beta package and the sample works well. Will this fix be available in a stable build soon?

Steve

Hi Steve,

Please download the package https://www.nuget.org/packages/ThinkGeo.MapSuite.Layers.Printers/10.2.1

Regards,

Ethan

1 Like