12 Replies - 2087 Views - Last Post: 24 February 2012 - 10:17 PM Rate Topic: -----

#1 EvanClark  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 05-January 12

Object reference not set to an instance

Posted 24 February 2012 - 04:43 PM

Here's my code
Form2_Load
{
    textbox1.Text = player.livesReamaining.ToString();
{


What I am doing is creating a debugger my form is supposed to track all
The variable in the XNA game the player.lives is an int so I converted to a string can
Someone please help

This post has been edited by tlhIn`toq: 24 February 2012 - 10:02 PM
Reason for edit:: code tags

Is This A Good Question/Topic? 0
  • +

Replies To: Object reference not set to an instance

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5949
  • View blog
  • Posts: 23,207
  • Joined: 23-August 08

Re: Object reference not set to an instance

Posted 24 February 2012 - 05:04 PM

Read this carefully and learn from it.
Was This Post Helpful? 1
  • +
  • -

#3 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4309
  • View blog
  • Posts: 7,456
  • Joined: 08-June 10

Re: Object reference not set to an instance

Posted 24 February 2012 - 05:07 PM

Ok, side note. It sounds like you're creating a Windows Form in XNA. It's likely that your player object hasn't been initialized when the form has. So you'll need to wait to show that form until your player object has been initialized.
Was This Post Helpful? 1
  • +
  • -

#4 EvanClark  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 05-January 12

Re: Object reference not set to an instance

Posted 24 February 2012 - 06:17 PM

Hello I have created a game in XNA but I am going to have a team working on it so I have decided to create a debugger which at run time a form shows up and has all the vAribiles in the game such as life score and current state and if it's possible editing the varibiles turning run time .the problem is I can't figure it
Out so I ask for your help I don't expect you to write
The whole thing ( but if you can:) ) just give me some leave and starting code like editing and displaying varibiles
Was This Post Helpful? 0
  • +
  • -

#5 superkb10  Icon User is offline

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 298
  • Joined: 27-November 11

Re: Object reference not set to an instance

Posted 24 February 2012 - 06:44 PM

Why don't you just send the entire project along with any images used in the game and have your friends just change the code and send it back to you.
Was This Post Helpful? 1
  • +
  • -

#6 EvanClark  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 05-January 12

Re: Object reference not set to an instance

Posted 24 February 2012 - 06:45 PM

C'mon should I do the debugger or not
Was This Post Helpful? 0
  • +
  • -

#7 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2216
  • View blog
  • Posts: 9,351
  • Joined: 29-May 08

Re: Object reference not set to an instance

Posted 24 February 2012 - 06:52 PM

How the <beep> should we know? It your project.
Does it require a Debugger? If so the write one.
Was This Post Helpful? 1
  • +
  • -

#8 EvanClark  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 05-January 12

Re: Object reference not set to an instance

Posted 24 February 2012 - 07:23 PM

Yes but how do I do it
Was This Post Helpful? -1
  • +
  • -

#9 Momerath  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 994
  • View blog
  • Posts: 2,380
  • Joined: 04-October 09

Re: Object reference not set to an instance

Posted 24 February 2012 - 08:52 PM

You'll need some way to 'attach' to the project. One way is shared memory streams and Mutex. Have the debugger write commands to the shared memory and the program responds with results.
Was This Post Helpful? 1
  • +
  • -

#10 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 856
  • View blog
  • Posts: 2,246
  • Joined: 28-March 11

Re: Object reference not set to an instance

Posted 24 February 2012 - 09:23 PM

Create a "Team" version. I don't know XNA, but it should go like this:

You create a window or console, then when you want a variable displayed, send it to that "debug" window or console.
Was This Post Helpful? 0
  • +
  • -

#11 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5316
  • View blog
  • Posts: 11,354
  • Joined: 02-June 10

Re: Object reference not set to an instance

Posted 24 February 2012 - 10:05 PM

Quote

has all the vAribiles in the game such as life score and current state and if it's possible editing the varibiles turning run time


So you and a team built an entire game in XNA - but didn't realize that Visual Studio's debugger already does this?

I don't understand why you want to re-invent the tools that you and your team already have.

Let's see... You can't figure out an "object reference not set to the instance of an object" error.. but you are going to build a debugger.
http://www.dreaminco...to-an-instance/

Does anyone else see a skill-level issue with this?


Oh - ANd don't open multiple threads for the same problem. I'm merging these two.
Was This Post Helpful? 1
  • +
  • -

#12 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4309
  • View blog
  • Posts: 7,456
  • Joined: 08-June 10

Re: Object reference not set to an instance

Posted 24 February 2012 - 10:10 PM

A lot of games include a type of console, that can be used to send commands, and print debugging messages. Bringing it up is usually bound to the backtick (`) key. It's part of the game itself, not an external program. Basically, it's a big textbox overlay.

I promise you, you'll have more trouble trying to manage inter-process communication between two applications than if you include a debug window in the program itself. You can't just try to use variables from one program in another, it doesn't work like that. Both programs have to be properly set up to communicate.
Was This Post Helpful? 1
  • +
  • -

#13 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5316
  • View blog
  • Posts: 11,354
  • Joined: 02-June 10

Re: Object reference not set to an instance

Posted 24 February 2012 - 10:17 PM

After scanning through your topics (questions you've asked) I just have to give you some advice:

STOP trying to make this game until you learn a little bit about programming. All of your questions are very, very basic. Like, first month of C# 101 basic. Like, you haven't gone through a single programming book from cover to cover yet, kind of basic.

You are by no means ready to try to design, then code a program from scratch.

The types of things in all of your posts are covered very early on in any self-teaching book. Which makes me think you really aren't ready to be designing an application yet.

Newbie/Rookie said:

I have a little programming experience but I need to write ...


You need to start there. I can't say "I have little experience in speaking Russian, but I have been assigned to write a mystery novel in Russian. Can you help me?"

We can help you by saying "First learn basic programming and the language of C#. Then take on assignments." Could someone here write this program for you? Sure. Could someone here map out all the processes you need to follow and do the Software Design part of this in the slim hope you could code it from there? Sure. But we don't volunteer to do the job that you're either getting paid for, or getting a grade for. You may want to read this.

For now, just work on the lessons. Do a self-teaching book from cover to cover. Then consider writing a program.

Don't try to create a useful working program to fit a need of yours (or a for-pay contract) as your introduction to coding project. When you are learning to code you don't know enough to code a program, let alone know how to engineer the architecture of a program. It would be like saying "I don't know how to read sheet music, or play an instrument. I think I'll write a 3 act opera as my first learning experience."

I don't say this to be mean. We've seen lots of new coders take this approach and we know it doesn't work. Trying to design your own programs before you understand the basics of the code language you've chosen just leads to problems, frustrations, and 'swiss-cheese' education (lots of holes).


Resources, references and suggestions for new programmers. - Updated Jan 2012
Spoiler






Please read FAQ 23:

TOP most asked:
What does this error message mean?
FAQ 2: How do I debug
FAQ 3: How do I make Form1 talk to Form2


FAQ (Frequently Asked Questions - Updated Feb 2012
Spoiler



Was This Post Helpful? 1
  • +
  • -

Page 1 of 1