This project has moved and is read-only. For the latest updates, please go here.

Silverlight version

Feb 10, 2012 at 4:08 PM
Edited Feb 10, 2012 at 4:51 PM

First of all, thanks a lot for your KML library, it works great.
I was actually looking for a robust KML lib that could work with both .Net and Silverlight (so it's possible to import/export KML file from a Silverlight application). I didn't found anything interesting I could use on the Internet, so I modified your code to support SL 4. You can download it here:

I didn't deeply tested it actually, but it works fine for the part of the lib I've used (I just tested KML export functionalities, so parse/kmz features are not yet tested). At least there isn't any regression with the NUnit tests you wrote for the .Net target (some tests fail but it's just like with the 15337 version of the available source code).
The Silverlight version is almost 100% iso-functional, the only things that are missing are related to KML/KMZ import from a file path (which doesn't make sense anyway from a non-trusted Silverlight application) and style resolution (as Silverlight can't synchronously download file from a specified URI). I've included the Silverlight version of Ionic.Zip.dll so SharKML_SL can support compressed streams (KMZ).

Maybe I'll have time next week to write some unit tests for the Silverlight version.

If you to make a diff with your current version, you'll see there isn't many modifications. Feel free to do what you want with the code I've wrote ;)

I hope next version of SharpKml will officially support SL!

Feb 10, 2012 at 5:29 PM

Thank you so much, that's awesome! Silverlight was the next thing to test after I tested mono, though I'm not quite happy with my development system just yet so won't be able to look at it until sometime next week (plus I've got some travelling to do from Monday to Wednesday so will probably be the end of the week before I can get the Silverlight tools installed).

What I might do is put some #if blocks around the non-compatible Silverlight parts and see if I can use the Silverlight version of DotNetZip for the desktop version as well (SharpKml doesn't use all of the features of DotNetZip so would simplify things if a common dll was needed by both versions of the library).

Thanks again and I'll get back to you next week with what I find.

Feb 10, 2012 at 5:42 PM

Unfortunately, even if Silverlight is a subset of the whole .Net framework, Silverlight assemblies are designed to be referenced by other Silverlight assemblies only.

Referencing a Silverlight assembly from a .Net assembly may work, but a warning will be thrown by Visual Studio. I would recommend using both version of DotNetZip (SL version for SL target, .Net version for .Net target)

Feb 10, 2012 at 7:08 PM

Thanks for the heads up - as you can tell I've done very little Silverlight development :)

Feb 10, 2012 at 7:41 PM

You're welcome ;) If you have any question, feel free to ask, I would be happy to help you.

Feb 26, 2012 at 9:40 PM

Sorry about the late reply, been busy lately.

I've created a Siverlight version (you'll need to download it from the Source Code section for the time being) and created a simple test page for testing for it. Some of the test initially failed because Silverlight doesn't allow private reflection but I've got them all to pass now (now I've got to try and get mono to play nicely with the Uri class).

Unfortunately, I can't get Kmz support to work as there is an issue with DotNetZip under Silverlight (see but if I get time I will try recompiling DotNetZip with the suggested changes on that page to enable limited Kmz support (the KmzFile class and unit tests have been updated to work under Silverlight, but as soon as an archive is unzipped a TypeInitializationException is thrown).