MapBox Crashing Visual Studio 2013

Topics: SharpMap Project, WinForms Controls
Feb 5, 2014 at 5:02 PM
Edited Feb 5, 2014 at 5:04 PM
I am getting a file not found exception when I add the MapBox control to a windows form in one particular app, the problem is that this exception causes VS to crash when trying to enter designer mode.

The solution was to take out the MapBox from the designer and add it after form initialization. I was wondering if anyone else faced a similar issue.

I was using the Sharpmap.UI Nuget Package in this app
Feb 6, 2014 at 7:50 AM
Edited Feb 6, 2014 at 7:55 AM
If you've added it using the desinger, you must have added it to the toolbox. Where did you point it to.
I assume the problem is that the folder, where the SharpMap.UI package places its content does not have a GeoAPI and or NetTopologySuite dll in it.

Therfore, place the contents of the GeoAPI, NetTopologySuite, SharpMap and SharpMap.UI nuget packages in a subdirectory and point the designer to that directory instead.

NuGet is not really for use with the VS designer. A VSIX project is more suitable.

Hth FObermaier
Feb 6, 2014 at 2:33 PM
I think the problem should lie somewhere else since the program does build and run properly.
Further if I place the mapbox initialization code as a separate function outside the InitializeComponent(); I am still able to use the designer for all other controls.

I found out about the "file not found exception" when reading windows application logs reg visual studio crash.

I have a feeling this could be related to some version mismatch or something like that, as I have already checked to see if the dll's are in place.

What I do not understand is that visual studio is not supposed to crash because of a control not initializing, but then sharp develop too crashed in a similar fashion when I tried to open the same form.

to sum up.
1) build works just fine
2) application works fine
3) visual studio works as long as I do not try to open the designer.
4) the crash is resolved by moving the mapbox init code outside the InitializeComponent method

Will update as I get a better idea of things :(
Feb 10, 2014 at 8:53 PM
I've investigated a little bit further.

In order for the designer not to crash, you need to reference some NTS class directly, e.g. var gf = new GeometryFactory();
Or you set GeometryServiceProvider.Instance = NetTopologySuite.NtsGeometryServices.Instance; directly.
If NTS is not in the AppDomain loaded by the designer, it is appearantly not loaded using the tweak by petlof.

I changed the implementation in the static SharpMap.Map constructor to the following:
    var instance = GeoAPI.GeometryServiceProvider.Instance;
    if (instance == null)
        throw new InvalidOperationException();
catch (InvalidOperationException)
    /*var ntsAssembly = */
    _logger.Debug("Loaded NetTopologySuite");
    var instance = GeoAPI.GeometryServiceProvider.Instance;
    if (instance == null)
        throw new InvalidOperationException();
This seems to work for the cases that previously failed
Feb 19, 2014 at 11:23 AM
The Mapbox works fine now in designer :) after updating to V 1.1.0