Hi Everyone,
I have run into a strange issue. On my development machine my code works fine and will draw a Google map onto a PDF without an issue. However, when I publish the site to our production server I get the following exception:
Error Message: System.ArgumentNullException: Value cannot be null.
Parameter name: ptr
at System.Runtime.InteropServices.Marshal.GetDelegateForFunctionPointer(IntPtr ptr, Type t)
at 3RM=.exw=.gRw=()
at 3RM=.exw=.lBw=(Bitmap lRw=, Double[] lhw=, String lxw=, String mBw=, Double[] mRw=)
at 3RM=.exw=.hRw=(Bitmap hhw=, RectangleShape hxw=, String iBw=, String iRw=, RectangleShape ihw=)
at ThinkGeo.MapSuite.Core.ManagedProj4Projection.ConvertToExternalProjectionCore(GeoImage image, RectangleShape imageExtent)
at ThinkGeo.MapSuite.Core.GoogleMapsLayer.U1k=(GeoCanvas VFk=)
at ThinkGeo.MapSuite.Core.GoogleMapsLayer.DrawCore(GeoCanvas canvas, Collection`1 labelsInAllLayers)
at ThinkGeo.MapSuite.Core.Layer.Draw(GeoCanvas canvas, Collection`1 labelsInAllLayers)
I have inserted code into our application to log if any parameters being passed in are null - but they are not. Is there something I failed to do on the server? I have the “Map Suite 7.0” and “MapSuiteFdoExtensionX86” folders in the System32 folder and I have installed the unmanaged dependencies. Any other thoughts on what would cause this exception only in our production environment?
Here is a sample of the code I’m using:
PdfDocument document = PdfReader.Open(Path.Combine(folderPath, file));PdfGeoCanvas canvas = new PdfGeoCanvas();PdfPage page = document.AddPage();
LayerOverlay staticOverlay = new LayerOverlay(“StaticMapOverlay”);GoogleMapsLayer googleLayer = new GoogleMapsLayer();googleLayer.ClientId = “[OUR_CLIENTID]”;googleLayer.PrivateKey = “[OUR_PRIVATE_KEY]”;googleLayer.MapType = GoogleMapsMapType.Hybrid;googleLayer.TileMode = GoogleMapsTileMode.SingleTile;staticOverlay.Layers.Add(googleLayer);map.CustomOverlays.Add(staticOverlay);
Collection<SimpleCandidate> labelsInLayers = new Collection<SimpleCandidate>();
RectangleShape zoomedExtents = ExtentHelper.ZoomToScale(map.ZoomLevelSet.ZoomLevel20.Scale, extent, GeographyUnit.Meter, (float)map.Width.Value, (float)map.Height.Value);
try{canvas.BeginDrawing(page, zoomedExtents, GeographyUnit.Meter);googleLayer.Open();googleLayer.Draw(canvas, labelsInLayers);canvas.EndDrawing();}catch (Exception ex){…}
Thank you for any insight you can provide,
Travis