Mobile Development: NullReferenceException
1 to 3 of 3
-
- CommentAuthorTrackS
- CommentTimeFeb 2nd 2011
I'm having some trouble setting up a windows mobile project and I'm hoping somebody can help me out. I've followed through the tutorials on the website and in the help documentation with no luck. I guess I have two issues that are probably related. When I get to the line in the function startRoute() that says "nMan.SetGps(new GpsSimulator(nMan.Navigator.Directions, 2));" I get a NullReferenceException. It looks like it's saying nMan.Navigator.Directions is null.
Also, if I comment this line out the program runs but where the mapCtrl should be, there is just a gray box. The code I'm using is below. I've made a few changes from the tutorial for debugging purposes but even if I copy the code right from the tutorial I get the same result. Any help would be appreciated..
Nathan
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telogis.GeoBase;
using Telogis.GeoBase.Repositories;
using Telogis.GeoBase.Navigation;
using Telogis.GeoBase.Routing;
using System.IO;
namespace DeviceApplication1
{
public partial class Form1 : Form
{
RendererList renderList = new RendererList();
NavigationManager nMan;
//Path for repository
string reposPath = @"USAPacWest.gbfs";
//Path for sound folder
string soundPath = "en-US";
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
#if DESKTOP
string resourcePath = @"C:\Program Files\Telogis\GeoBase\GeoBaseResources";
#else
string resourcePath = @"\Storage Card";
#endif
//Set up data repository
string repopath = Path.Combine(resourcePath, reposPath);
if(File.Exists(repopath)) {
Repository.Default = new MultiRepository(repopath);
//Repository.Default = new MultiRepository(Path.Combine(resourcePath, reposPath));
//Set up nav manager
string sound = Path.Combine(resourcePath, soundPath);
nMan = new NavigationManager(mapMain, sound);
//Add to renderer list
mapMain.Renderer = renderList;
renderList.Add(nMan);
startRoute();
}
}
private void startRoute()
{
//Set the gps for the navigation manager
//using StaticGps and starting address (latlon)
nMan.SetGps(new StaticGps(33.71581, -117.77641));
//Set destination
nMan.SetDestination(new LatLon(33.65006, -117.75523));
//Set the gps for the navigation manager
nMan.SetGps(new GpsSimulator(nMan.Navigator.Directions, 2));
}
private void menuItemReset_Click(object sender, EventArgs e)
{
//Call startRoute() to reset route
startRoute();
}
private void menuItemExit_Click(object sender, EventArgs e)
{
//power down GPS unit, before exiting.
nMan.Navigator.Gps.PowerDown();
Application.Exit();
}
}
} -
- CommentAuthorSharonD
- CommentTimeFeb 6th 2011
Hi Nathan,
Since you have sent the same information to gbsupport, we will deal with your issue in a support case.
Kind regards,
Sharon -
- CommentAuthornixbure
- CommentTimeMar 12th 2011
Hi Nathan, maybe the error is on the Repospath variable you don't have to specify the name of the gbfs File. You only have to put the folder of it. If the path is on "\\Storage Card\" you should change the Repospath=""
1 to 3 of 3
