ThinkGeo.com    |     Documentation    |     Premium Support

Error when displaying deserialized WPFMap

Hi, I’m currently reviewing your library to use in my company’s project

I’m having trouble displaying a wpf map after it has been deserialized.

My program first create a empty wpf map, and then add a GeoTiffRasterLayer.
When the save button is clicked, the wpf map is serialized and saved into a file.

The trouble appear when the program tried to open the save file, deserialize the wpf map and display it the window.

The deserialize process finisihed without problem. However the error “System.AccessViolationException’ occurred in System.Drawing.dll” appeared when it tried to display the wpf map.

The full error:
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Drawing.SafeNativeMethods.Gdip.IntGdipDisposeImage(HandleRef image)
at System.Drawing.SafeNativeMethods.Gdip.GdipDisposeImage(HandleRef image)
at System.Drawing.Image.Dispose(Boolean disposing)
at System.Drawing.Image.Finalize()

Any idea what is causing this?

Hi Yohan,

I did a sample which works with our latest version package, and it works well.

Please put your data into the AppData folder and try this project:

8891.zip (10.3 KB)

Wish that’s helpful.

Regards,

Ethan

Hi Ethan.

After some modification, I was able to replicate the error that I encountered.

Please run the attached solution and click the “deserialize” button.
deserialize sample.zip (282.7 KB)

Note: the tif file is too big to upload. It can be found on this link:
http://www.terracolor.net/download/tc_ng_sfbay_us_geotiff.zip
Please extract the tif file on the appdata folder

Hi Yohan,

Thanks for your project and data, but it looks I just get this exception: Value was either too large or too small for a Double.

And I found that thrown because this value in the XML: 1,7976931348623157E+308

So could you please view your code to see whether you set the maximumScale for map, and you can also try to show us your code about serialize the map.

Regards,

Ethan

Hi Ethan,

the value “1,7976931348623157E+308” in the xml is the max value for double, so it shouldn’t be a problem.

Attached is the revised code.

Please click “create map” first and then “serialize”.
After that close the program and re run the code.
Click “deserialize”. You should get the error then.
deserialize sample - 3.zip (273.0 KB)

Hi Yohan,

I think that should be solved when we solve some other project.

Please just upgrade all the package to latest development version and run your project again. You can found it works now.

deserialize sample - 3.zip (11.0 KB)

Regards,

Ethan

Hi Ethan,

I have upgraded all the package to the latest development version.

The error still appears when I clicked deserialize.

I have tried deleting the old “test.xml” , click “create map” and then “serialize”. Nothing changed.

Hi Yohan,

Please download my sample and try it. I test that today again, it works in my end.

And you can clear your cached Nuget package before that, some of them are located in these folders as below:

%LocalAppData%\..\..\.nuget\packages

%LocalAppData%\NuGet\Cache

Regards,

Ethan

Hi Ethan,

I have cleared the cached nuget package and tried the attached sample.

Here is the result:

  1. if I click “create map”, "serialize"and then “deserialize” on the same session ( without closing and re opening the sample program), it works fine.

  2. If I click “deserialize” immediately after closing and reopening the sample program, I got the System.AccessViolationException error

I have also tried the sample program on my colleague 's computer with the same result.

Hi Yohan,

Please see my tested steps in the gif, and if you found I missed any point to reproduce it please let me know.

The test sample is the deserialize sample - 3.zip.

Regards,

Ethan

Hi Ethan,

From the gif, you have not missed any steps.

The error still appeared on my machine. I have tested “deserialize sample - 3.zip” in three different machines. All of them throw the exception when deserializing.

Maybe the error is limited for machines that uses the trial account?

Could you retest the sample using a trial account?

Hi Yohan,

I have reproduced that, you’re right that’s because the version reason. Full version works well but eval get the same exception like you mentioned.

Our developer will look into this and see what’s the reason of it, any update I will let you know.

Regards,

Ethan

Hi Ethan,

Glad to know that the full version do not have this problem.

Please let me know when there is any update.

Hi Yohan,

Does that’s hurry for you? Because this problem is not easy to be fixed, so if that’s a important for you please let us know, We will improve the priority of this task and spend more resource on solve it.

Regards,

Ethan

Hi Ethan,

As long as the problem does not affect the full version, it is not a high priority.

Hi Yohan,

This bug has been fixed on latest package, it is only available on latest pre-release package.
You can get this fixing in https://www.nuget.org/packages/ThinkGeo.MapSuite/11.0.0-beta058

This change will be applied on stable package on next minor release. The next minor release will be publish in next two monthes.

If you meet any issue, please feel free to let us know that.

Thanks
Mark