Help me! What's wrong with my code?

Feb 17, 2010 at 5:02 PM
Edited Feb 17, 2010 at 5:02 PM

Please help me! What's wrong with my code?

My code is at the bottom of this article. I work in Visual Studio 2008 Professional sp1 and Windows 7 64 bit. I made a project for Windows Mobile Device, and currently have 6.0, 6.1, 6.5 SDK installed. I ran my code in Sony Erricson's Xperia X1 running WM 6.5.

Here is initial part of error message:

'Test.Mine.exe' (Managed): Loaded 'C:\Program Files (x86)\Microsoft.NET\SDK\CompactFramework\v2.0\WindowsCE\mscorlib.dll'
'Test.Mine.exe' (Managed): Loaded 'c:\users\USER\desktop\greatmaps-46320\trunk\test.mine\bin\debug\Test.Mine.exe', Symbols loaded.
'Test.Mine.exe' (Managed): Loaded 'System.Windows.Forms.dll'
'Test.Mine.exe' (Managed): Loaded 'System.dll'
'Test.Mine.exe' (Managed): Loaded 'System.Drawing.dll'
'Test.Mine.exe' (Managed): Loaded 'c:\users\USER\desktop\greatmaps-46320\trunk\gmap.net.windowsmobile\bin\debug\GMap.NET.WindowsMobile.dll', Symbols loaded.
------------------
OnTileLoadStart: 8 tiles to load at zoom 5, time: 01:49:25
OnTileLoadStart: 15 tiles to load at zoom 5, time: 01:49:25
Starting GetResponse: {X=0,Y=1}
Starting GetResponse: {X=0,Y=3}
A first chance exception of type 'System.SystemException' occurred in mscorlib.dll
'Test.Mine.exe' (Managed): Loaded 'System.SR.dll'
A first chance exception of type 'System.SystemException' occurred in mscorlib.dll
The thread 0x6ba96a9a has exited with code 0 (0x0).
The thread 0x251f4eae has exited with code 0 (0x0).
A first chance exception of type 'System.SystemException' occurred in mscorlib.dll
The thread 0x6ba96a9a has exited with code 0 (0x0).
A first chance exception of type 'System.SystemException' occurred in mscorlib.dll
The thread 0x251f4eae has exited with code 0 (0x0).
A first chance exception of type 'System.SystemException' occurred in mscorlib.dll
      exception occurs ....

This is my test code, almost from your Demo.WindowsMobile project. 
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using GMap.NET;
using GMap.NET.WindowsForms;
using GMap.NET.WindowsForms.Markers;

namespace Test.Mine
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void menuItem1_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            Close(); // I don't know why but the first form of a process would not close properly. So force to close.
        }


        PointLatLng start = new PointLatLng(37.6961334816182, 127.2985095977783);
        GMapControl mapControl;

        // marker
        GMapMarkerCross center;

        // layers
        GMapOverlay top;
        GMapOverlay objects;
        GMapOverlay routes;

        private void Form1_Load(object sender, EventArgs e)
        {
            SuspendLayout();
            mapControl = new GMapControl();
            mapControl.BackColor = System.Drawing.Color.White;
            mapControl.CanDragMap = true;
            mapControl.Dock = System.Windows.Forms.DockStyle.Fill;
            mapControl.Location = new System.Drawing.Point(0, 0);
            mapControl.MapType = GMap.NET.MapType.GoogleMap;
            mapControl.MarkersEnabled = true;
            mapControl.Name = "mapControl";
            mapControl.RoutesEnabled = true;
            mapControl.ShowTileGridLines = false;
            mapControl.Size = new System.Drawing.Size(480, 696);
            mapControl.TabIndex = 0;
            //mapControl.Zoom = 0;
            Controls.Add(this.mapControl);
            ResumeLayout();

            mapControl.Manager.Mode = AccessMode.ServerOnly;
            mapControl.MapType = MapType.GoogleMap;
            mapControl.MaxZoom = 11;
            mapControl.MinZoom = 1;
            mapControl.Zoom = 5;
            mapControl.CurrentPosition = start;

            //mapControl.CacheLocation = "/";
            mapControl.OnCurrentPositionChanged += new CurrentPositionChanged(mapControl_OnCurrentPositionChanged);

            // add custom layers  
            {
                routes = new GMapOverlay(mapControl, "routes");
                mapControl.Overlays.Add(routes);

                objects = new GMapOverlay(mapControl, "objects");
                mapControl.Overlays.Add(objects);

                top = new GMapOverlay(mapControl, "top");
                mapControl.Overlays.Add(top);
            }

            // map center
            center = new GMapMarkerCross(mapControl.CurrentPosition);
            top.Markers.Add(center);
        }

        void mapControl_OnCurrentPositionChanged(PointLatLng point)
        {
            center.Position = point;
        }


    }
}

Thanks,
laphir.

 

Feb 17, 2010 at 5:19 PM

Not sure if this will help or not, but this might be the problem since your running 64 bit   http://greatmaps.codeplex.com/documentation.

Feb 17, 2010 at 5:41 PM

mapControl.Manager.Mode = AccessMode.ServerOnly; // so you made yourself absolutely dependent on Internet connection ;}