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

Sharpmap used with Mono will not show WMS layer - now it can!!!

Topics: SharpMap Project, SharpMap v0.9 / v1.x, WinForms Controls
Dec 11, 2009 at 12:24 AM

Sharpmap 0.9 - Edited to work in mono!

All the following was done in Ubuntu 9.10 (AMD64bit) - Monodevelop 2.0 - Mono JIT compiler version (Debian

My problem was, i could not get a image to the winform (mono) or from the _imageMap.getMap(); just
a blank picture, with a background!.

After a hard strugle I finally found the problem. In the /SharpMap/Layers/WmsLayer.cs in the Render method
the WebRequest.Method was set, if I comment the line out it suddenly worked.

public override void Render(System.Drawing.Graphics g, Map map)
            SharpMap.Web.Wms.Client.WmsOnlineResource resource = GetPreferredMethod();            
            Uri myUri = new Uri(GetRequestUrl(map.Envelope,map.Size));
            System.Net.WebRequest myWebRequest = System.Net.WebRequest.Create(myUri);
            //myWebRequest.Method = resource.Type;
            myWebRequest.Timeout = _TimeOut;
            if (_Credentials != null)
                myWebRequest.Credentials = _Credentials;

This solution to the problem is not new, when I first ran into the problem i read somewhere in the sharpmap forum that both lines
(method and timeout) should be removed, but the full solution was not provided! (Not in my eyes, sorry if I am wrong!) And therefor I did not understand what to do.

But now I can use sharpmap in mono (Use it with winforms)
And I learned some things along the road about how to compile sharpmap.

All the dll files you should use is in the outer folder named: SharpMapLib!

If you will correct/edit more things, you can open the solution sln, all the needed projekt and dll should be their!

All the files is in this zip package:

Hope this help someone, it help me!
//Frits - (Software developer in 3 years)

Contact me if I have done something wrong.