system.null reference exception

G

Guest

Hi peter,
Sorry I missed the new keyword in the post.
Actually the "new" keyword is there in my code.Here is my code.

using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using SampleMap1.mapref;
using System.Net;
using System.Diagnostics;
using System.Web.Services;

namespace SampleMap1
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.MainMenu mainMenu1;



public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.button1 = new System.Windows.Forms.Button();
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(24, 16);
this.pictureBox1.Size = new System.Drawing.Size(168, 216);
//
// button1
//
this.button1.Location = new System.Drawing.Point(40, 256);
this.button1.Size = new System.Drawing.Size(72, 24);
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.ClientSize = new System.Drawing.Size(266, 296);
this.Controls.Add(this.button1);
this.Controls.Add(this.pictureBox1);
this.Menu = this.mainMenu1;
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>

static void Main()
{
Application.Run(new Form1());
}

private void Form1_Load(object sender, System.EventArgs e)
{

}

private void button1_Click(object sender, System.EventArgs e)
{
string MPUID = "XXXXX";
string MPPW = "XXXXXX";
FindServiceSoap findService = new FindServiceSoap();
FindSpecification findSpec = new FindSpecification();
findService.Credentials = new NetworkCredential(MPUID, MPPW);
findService.PreAuthenticate =true;

findSpec.DataSourceName = "MapPoint.NA";
findSpec.InputPlace = "Seattle, WA";

FindResults foundResults = findService.Find(findSpec);

ViewByHeightWidth[] myViews = new ViewByHeightWidth[1];
myViews[0] = foundResults.Results[0].FoundLocation.BestMapView.ByHeightWidth;

RenderServiceSoap renderService = new RenderServiceSoap();
renderService.Credentials = new NetworkCredential(MPUID, MPPW);

MapSpecification mapSpec = new MapSpecification();
mapSpec.DataSourceName = "MapPoint.NA";
mapSpec.Views = myViews;

MapImage[] mapImages = renderService.GetMap(mapSpec);

System.IO.Stream streamImage;
streamImage = new System.IO.MemoryStream(mapImages[0].MimeData.Bits);
Bitmap bitmapImage = new Bitmap(streamImage);
pictureBox1.Image = bitmapImage;

}
}
}

Thanks
latha.
 
A

Alex Feinman [MVP]

So is one of the following equal to null?
mapImages
mapImages[0]
mapImages[0].MimeData
mapImages[0].MimeData.Bits

If all of the above are non-null, try dumping mapImages[0].MimeData.Bits
into a file (using FileStream.Write), copy it to the desktop and examine it

--
Alex Feinman
---
Visit http://www.opennetcf.org
latha said:
Hi peter,
Sorry I missed the new keyword in the post.
Actually the "new" keyword is there in my code.Here is my code.

using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using SampleMap1.mapref;
using System.Net;
using System.Diagnostics;
using System.Web.Services;

namespace SampleMap1
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.MainMenu mainMenu1;



public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.button1 = new System.Windows.Forms.Button();
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(24, 16);
this.pictureBox1.Size = new System.Drawing.Size(168, 216);
//
// button1
//
this.button1.Location = new System.Drawing.Point(40, 256);
this.button1.Size = new System.Drawing.Size(72, 24);
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.ClientSize = new System.Drawing.Size(266, 296);
this.Controls.Add(this.button1);
this.Controls.Add(this.pictureBox1);
this.Menu = this.mainMenu1;
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>

static void Main()
{
Application.Run(new Form1());
}

private void Form1_Load(object sender, System.EventArgs e)
{

}

private void button1_Click(object sender, System.EventArgs e)
{
string MPUID = "XXXXX";
string MPPW = "XXXXXX";
FindServiceSoap findService = new FindServiceSoap();
FindSpecification findSpec = new FindSpecification();
findService.Credentials = new NetworkCredential(MPUID, MPPW);
findService.PreAuthenticate =true;

findSpec.DataSourceName = "MapPoint.NA";
findSpec.InputPlace = "Seattle, WA";

FindResults foundResults = findService.Find(findSpec);

ViewByHeightWidth[] myViews = new ViewByHeightWidth[1];
myViews[0] = foundResults.Results[0].FoundLocation.BestMapView.ByHeightWidth;

RenderServiceSoap renderService = new RenderServiceSoap();
renderService.Credentials = new NetworkCredential(MPUID, MPPW);

MapSpecification mapSpec = new MapSpecification();
mapSpec.DataSourceName = "MapPoint.NA";
mapSpec.Views = myViews;

MapImage[] mapImages = renderService.GetMap(mapSpec);

System.IO.Stream streamImage;
streamImage = new System.IO.MemoryStream(mapImages[0].MimeData.Bits);
Bitmap bitmapImage = new Bitmap(streamImage);
pictureBox1.Image = bitmapImage;

}
}
}

Thanks
latha.
 
G

Guest

Hi
I think it is the cause for my problem. But I am facing problems while downloading the Service packs.
From the STEVEN PUSHEE answer,I didn't understand how to open the pocketpc emulator and copy the things.
My operating system is windows xp.(home).
Can anyone explain me detail procedure for doing that..?

please go thru this link.
http://msdn.microsoft.com/newsgroup...F-425F-AC2B-DC48AB0DA5C9&dglist=&ptlist=&exp=

Alex Feinman said:
So is one of the following equal to null?
mapImages
mapImages[0]
mapImages[0].MimeData
mapImages[0].MimeData.Bits

If all of the above are non-null, try dumping mapImages[0].MimeData.Bits
into a file (using FileStream.Write), copy it to the desktop and examine it

--
Alex Feinman
---
Visit http://www.opennetcf.org
latha said:
Hi peter,
Sorry I missed the new keyword in the post.
Actually the "new" keyword is there in my code.Here is my code.

using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using SampleMap1.mapref;
using System.Net;
using System.Diagnostics;
using System.Web.Services;

namespace SampleMap1
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.MainMenu mainMenu1;



public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.button1 = new System.Windows.Forms.Button();
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(24, 16);
this.pictureBox1.Size = new System.Drawing.Size(168, 216);
//
// button1
//
this.button1.Location = new System.Drawing.Point(40, 256);
this.button1.Size = new System.Drawing.Size(72, 24);
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.ClientSize = new System.Drawing.Size(266, 296);
this.Controls.Add(this.button1);
this.Controls.Add(this.pictureBox1);
this.Menu = this.mainMenu1;
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>

static void Main()
{
Application.Run(new Form1());
}

private void Form1_Load(object sender, System.EventArgs e)
{

}

private void button1_Click(object sender, System.EventArgs e)
{
string MPUID = "XXXXX";
string MPPW = "XXXXXX";
FindServiceSoap findService = new FindServiceSoap();
FindSpecification findSpec = new FindSpecification();
findService.Credentials = new NetworkCredential(MPUID, MPPW);
findService.PreAuthenticate =true;

findSpec.DataSourceName = "MapPoint.NA";
findSpec.InputPlace = "Seattle, WA";

FindResults foundResults = findService.Find(findSpec);

ViewByHeightWidth[] myViews = new ViewByHeightWidth[1];
myViews[0] = foundResults.Results[0].FoundLocation.BestMapView.ByHeightWidth;

RenderServiceSoap renderService = new RenderServiceSoap();
renderService.Credentials = new NetworkCredential(MPUID, MPPW);

MapSpecification mapSpec = new MapSpecification();
mapSpec.DataSourceName = "MapPoint.NA";
mapSpec.Views = myViews;

MapImage[] mapImages = renderService.GetMap(mapSpec);

System.IO.Stream streamImage;
streamImage = new System.IO.MemoryStream(mapImages[0].MimeData.Bits);
Bitmap bitmapImage = new Bitmap(streamImage);
pictureBox1.Image = bitmapImage;

}
}
}

Thanks
latha.
 
A

Alex Feinman [MVP]

Ah, I see. I don't remember which bug in RTM Steven refers to, but the
easiest way to copy a cab to the emulator is to use File Explorer on the
emulator to connect to a network share on another machine (even one where
emulator is running).

Another option would be HTTP download (again initiated from the device).
Just put the cab on your web server and point Pocket IE inside the emulator
to it. Make sure the you are using the cab built for X86 and not ARM


--
Alex Feinman
---
Visit http://www.opennetcf.org
latha said:
Hi
I think it is the cause for my problem. But I am facing problems while downloading the Service packs.
From the STEVEN PUSHEE answer,I didn't understand how to open the
pocketpc emulator and copy the things.
My operating system is windows xp.(home).
Can anyone explain me detail procedure for doing that..?

please go thru this link.
http://msdn.microsoft.com/newsgroup...F-425F-AC2B-DC48AB0DA5C9&dglist=&ptlist=&exp=

Alex Feinman said:
So is one of the following equal to null?
mapImages
mapImages[0]
mapImages[0].MimeData
mapImages[0].MimeData.Bits

If all of the above are non-null, try dumping mapImages[0].MimeData.Bits
into a file (using FileStream.Write), copy it to the desktop and examine it

--
Alex Feinman
---
Visit http://www.opennetcf.org
latha said:
Hi peter,
Sorry I missed the new keyword in the post.
Actually the "new" keyword is there in my code.Here is my code.

using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using SampleMap1.mapref;
using System.Net;
using System.Diagnostics;
using System.Web.Services;

namespace SampleMap1
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.MainMenu mainMenu1;



public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.button1 = new System.Windows.Forms.Button();
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(24, 16);
this.pictureBox1.Size = new System.Drawing.Size(168, 216);
//
// button1
//
this.button1.Location = new System.Drawing.Point(40, 256);
this.button1.Size = new System.Drawing.Size(72, 24);
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.ClientSize = new System.Drawing.Size(266, 296);
this.Controls.Add(this.button1);
this.Controls.Add(this.pictureBox1);
this.Menu = this.mainMenu1;
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>

static void Main()
{
Application.Run(new Form1());
}

private void Form1_Load(object sender, System.EventArgs e)
{

}

private void button1_Click(object sender, System.EventArgs e)
{
string MPUID = "XXXXX";
string MPPW = "XXXXXX";
FindServiceSoap findService = new FindServiceSoap();
FindSpecification findSpec = new FindSpecification();
findService.Credentials = new NetworkCredential(MPUID, MPPW);
findService.PreAuthenticate =true;

findSpec.DataSourceName = "MapPoint.NA";
findSpec.InputPlace = "Seattle, WA";

FindResults foundResults = findService.Find(findSpec);

ViewByHeightWidth[] myViews = new ViewByHeightWidth[1];
myViews[0] = foundResults.Results[0].FoundLocation.BestMapView.ByHeightWidth;

RenderServiceSoap renderService = new RenderServiceSoap();
renderService.Credentials = new NetworkCredential(MPUID, MPPW);

MapSpecification mapSpec = new MapSpecification();
mapSpec.DataSourceName = "MapPoint.NA";
mapSpec.Views = myViews;

MapImage[] mapImages = renderService.GetMap(mapSpec);

System.IO.Stream streamImage;
streamImage = new System.IO.MemoryStream(mapImages[0].MimeData.Bits);
Bitmap bitmapImage = new Bitmap(streamImage);
pictureBox1.Image = bitmapImage;

}
}
}

Thanks
latha.
 
G

Guest

Hi.

MY problem was solved.. I just followed the procedure mentioned by STEVEN.
I am able to display map.
Thanks,
latha

Alex Feinman said:
Ah, I see. I don't remember which bug in RTM Steven refers to, but the
easiest way to copy a cab to the emulator is to use File Explorer on the
emulator to connect to a network share on another machine (even one where
emulator is running).

Another option would be HTTP download (again initiated from the device).
Just put the cab on your web server and point Pocket IE inside the emulator
to it. Make sure the you are using the cab built for X86 and not ARM


--
Alex Feinman
---
Visit http://www.opennetcf.org
latha said:
Hi
I think it is the cause for my problem. But I am facing problems while downloading the Service packs.
From the STEVEN PUSHEE answer,I didn't understand how to open the
pocketpc emulator and copy the things.
My operating system is windows xp.(home).
Can anyone explain me detail procedure for doing that..?

please go thru this link.
http://msdn.microsoft.com/newsgroup...F-425F-AC2B-DC48AB0DA5C9&dglist=&ptlist=&exp=

Alex Feinman said:
So is one of the following equal to null?
mapImages
mapImages[0]
mapImages[0].MimeData
mapImages[0].MimeData.Bits

If all of the above are non-null, try dumping mapImages[0].MimeData.Bits
into a file (using FileStream.Write), copy it to the desktop and examine it

--
Alex Feinman
---
Visit http://www.opennetcf.org
Hi peter,
Sorry I missed the new keyword in the post.
Actually the "new" keyword is there in my code.Here is my code.

using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using SampleMap1.mapref;
using System.Net;
using System.Diagnostics;
using System.Web.Services;

namespace SampleMap1
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.MainMenu mainMenu1;



public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.button1 = new System.Windows.Forms.Button();
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(24, 16);
this.pictureBox1.Size = new System.Drawing.Size(168, 216);
//
// button1
//
this.button1.Location = new System.Drawing.Point(40, 256);
this.button1.Size = new System.Drawing.Size(72, 24);
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.ClientSize = new System.Drawing.Size(266, 296);
this.Controls.Add(this.button1);
this.Controls.Add(this.pictureBox1);
this.Menu = this.mainMenu1;
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>

static void Main()
{
Application.Run(new Form1());
}

private void Form1_Load(object sender, System.EventArgs e)
{

}

private void button1_Click(object sender, System.EventArgs e)
{
string MPUID = "XXXXX";
string MPPW = "XXXXXX";
FindServiceSoap findService = new FindServiceSoap();
FindSpecification findSpec = new FindSpecification();
findService.Credentials = new NetworkCredential(MPUID, MPPW);
findService.PreAuthenticate =true;

findSpec.DataSourceName = "MapPoint.NA";
findSpec.InputPlace = "Seattle, WA";

FindResults foundResults = findService.Find(findSpec);

ViewByHeightWidth[] myViews = new ViewByHeightWidth[1];
myViews[0] =
foundResults.Results[0].FoundLocation.BestMapView.ByHeightWidth;

RenderServiceSoap renderService = new RenderServiceSoap();
renderService.Credentials = new NetworkCredential(MPUID, MPPW);

MapSpecification mapSpec = new MapSpecification();
mapSpec.DataSourceName = "MapPoint.NA";
mapSpec.Views = myViews;

MapImage[] mapImages = renderService.GetMap(mapSpec);

System.IO.Stream streamImage;
streamImage = new System.IO.MemoryStream(mapImages[0].MimeData.Bits);
Bitmap bitmapImage = new Bitmap(streamImage);
pictureBox1.Image = bitmapImage;

}
}
}

Thanks
latha.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top