Author Topic: Object reference not set to an instance of an object.  (Read 14474 times)

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Object reference not set to an instance of an object.
« on: 2007-03-07, 12:57:43 AM »
I'm not sure if I stuffed something up while making my project, or alpha 2 is the reason it's stuffing up. I just got alpha 2 from alpha 1. Project used to run in alpha 1, although i edited some things i didn't test before I got alpha 2 so it's possible I stuffed it up without relising it. Hope you could understand that, it was a mouthful, anyway, here's the error from the log viewer.

Test Project\Frameset.cs(218,56) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\MapBase.cs(57,17) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\MapBase.cs(63,17) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\MapBase.cs(142,39) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\LayerBase.cs(71,80) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(23,7) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(30,7) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(36,28) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(38,10) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(39,8) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(45,28) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(49,39) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(50,7) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(56,14) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(62,7) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(74,29) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(89,39) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(92,38) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(136,11) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(142,35) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(201,16) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(204,19) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(207,13) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(209,13) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(211,13) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(264,7) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(270,7) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(286,10) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(288,10) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(300,7) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(306,7) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GeneralRules.cs(312,14) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\PlanBase.cs(290,26) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\PlanBase.cs(296,24) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Controls.cs(49,11) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Controls.cs(56,26) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Controls.cs(57,34) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Controls.cs(60,25) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Controls.cs(405,13) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Controls.cs(407,13) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Controls.cs(426,20) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Controls.cs(432,47) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Controls.cs(454,29) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Controls.cs(464,11) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Controls.cs(466,50) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Controls.cs(480,42) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Display.cs(306,33) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Display.cs(622,14) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GameForm.cs(54,43) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GameForm.cs(150,41) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GameForm.cs(152,40) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\GameForm.cs(153,68) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\About.cs(30,25) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\CollisionMask.cs(167,48) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\SpriteBase.cs(713,28) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\SpriteBase.cs(720,26) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\SpriteBase.cs(725,24) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Player.cs(132,17) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Player.cs(140,17) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Player.cs(148,17) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Player.cs(156,17) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Player.cs(164,17) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Player.cs(172,17) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Player.cs(180,17) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Player.cs(188,17) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Player.cs(214,17) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Player.cs(222,17) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Player.cs(230,17) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Player.cs(238,17) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Player.cs(246,17) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Player.cs(254,17) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Player.cs(262,17) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)
Test Project\Player.cs(270,17) : error CS0246: The type or namespace name 'Project' could not be found (are you missing a using directive or an assembly reference?)


It appears I'm somehow missing all the source code from my project, lol.  ;D  I'm just glad I was able to copy and paste, I would never type all that out.   ;)

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Object reference not set to an instance of an object.
« Reply #1 on: 2007-03-07, 06:37:22 AM »
Select "Reset Source Code" from the File menu.  This will replace all pre-defined source code files in the project (the ones that have an icon that looks like a page of text, not the ones with question marks) with the new version from alpha 2.  Then try compiling the project.  If that works, then save your project.  Don't do this if you have put a lot of work into customizing the source code, because it will be replaced.

Details:
Compiling an SGDK2 project includes 3 kinds of source code files: 1. Customizable source code (shows up in the Source Code folder as a sheet with text); 2. User-defined source code (shows up in the Source Code folder as a sheet with a question mark) and 3. Generated source code (does not show up in the Source Code folder).  Alpha release 1 was treating Project.cs as Generated source code.  So when alpha release 1 creates a new project for you, it doesn't put a Project.cs in the project because that would conflict with the generated file.  Alpha 2 converted changed to treat Project.cs as a customizable file.  That means it no longer generates this file; it expects it to be in the project.  Since SGDK2 only adds files to the project when you ask it to (when a new project is created or when you select Reset Source Code), your alpha 1 project loaded as-is without Project.cs.  Since alpha 2 was no longer generating this file, all your error messages about "Project" were complaining about the missing Project.cs file.  When you select "Reset Source Code", it tells SGDK2 to reset all the customizable code objects to what it expects to see in a new project.  So, among other things, that will add Project.cs to your project.

After you make this change, it's possible some of your rules might cause errors.  I may have changed the number of parameters on some rules you might have been using, and after you reset the source code, it might complain about the wrong number of parameters being used in some of your rules.  But if that happens, it should be relatively easy to fix the rules if you can find where they're being used (in the Sprite Definition Rules tab or the Plan Rules).

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Re: Object reference not set to an instance of an object.
« Reply #2 on: 2007-03-08, 12:31:53 AM »
I can now compile it but still not run it. I get, http://www.box.net/public/psi31f5osd  Sorry can't be stuffed typing it.


bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Object reference not set to an instance of an object.
« Reply #3 on: 2007-03-08, 07:09:32 AM »
Oops.  I neglected to properly handle spaces in map names in the new project.cs.  To fix it, open your project, open the SourceCode folder, open Project.cs and search for "_StartupMapType".  After the ")" that comes after that add .Replace(" ","_"). (There's a space between the first pair of double-quotes and an underscore in the second -- this replaces spaces with underscores.)  Then do the same for "_OverlayMapType". So you should have a couple expressions that looks like this:
Code: [Select]
... m_res.GetString("_StartupMapType").Replace(" ","_") + "_Map" ...
... m_res.GetString("_OverlayMapType").Replace(" ","_") + "_Map" ...

That should fix your problem.

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Re: Object reference not set to an instance of an object.
« Reply #4 on: 2007-03-09, 12:29:13 AM »
Now i get,

Code: [Select]
Test Project\Project.cs(53,14) : error CS0131: The left-hand side of an assignment must be a variable, property or indexer
Test Project\Project.cs(53,14) : error CS0029: Cannot implicitly convert type 'string' to 'bool'

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Object reference not set to an instance of an object.
« Reply #5 on: 2007-03-09, 06:54:39 AM »
Show me the two lines of Project.cs that you edited.

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Re: Object reference not set to an instance of an object.
« Reply #6 on: 2007-03-09, 03:42:56 PM »
Here you go,

Code: [Select]
overlayMapType = System.Reflection.Assembly.GetExecutingAssembly().GetType(m_res.GetString("_OverlayMapType").Replace(" ","_") + "_Map", true);

System.Type startupMapType = System.Reflection.Assembly.GetExecutingAssembly().GetType(m_res.GetString("_StartupMapType").Replace(" ","_") + "_Map", true);

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: Object reference not set to an instance of an object.
« Reply #7 on: 2007-03-09, 04:20:08 PM »
open Project.cs and press [CTRL]+G and type in 53 and hit enter.  This will take you to line 53, where the error occurred.  My line 53 looks like this:

if (m_res.GetString("_OverlayMapType") != null)

What does yours look like?
Edward Dassmesser

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Re: Object reference not set to an instance of an object.
« Reply #8 on: 2007-03-09, 04:24:32 PM »
Mine is slightly different,

Code: [Select]
if (m_res.GetString("_OverlayMapType")= null)
But if I fix mine to make it the same as yours I just get another error.
http://www.box.net/public/ulzuvs0yp6
« Last Edit: 2007-03-09, 04:30:32 PM by Jam0864 »

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: Object reference not set to an instance of an object.
« Reply #9 on: 2007-03-09, 05:51:20 PM »
Well, that was the solution.  You seem to have accidentally removed the "!" in that line.

The new error means you are getting further along the line.  Do you have DirectX 9 installed?  Are there DirectX files in the same directory as SGDK2?
Edward Dassmesser

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Re: Object reference not set to an instance of an object.
« Reply #10 on: 2007-03-09, 06:40:43 PM »
Yes, got directX 9 from Counter-Strike.Yes there is 4 directX files in the SGDK2 directory. There is,

Microsoft.DirectX.Direct3D.dll
Microsoft.DirectX.Direct3DX.dll
Microsoft.DirectX.DirectInput.dll
Microsoft.DirectX.dll

I'm not sure if d3dx9_30.dll is a directX file, if it is I have 5 directX files. I had the same error when I first installed alpha 1. I can't remember the solution but it's somewhere in this forum.

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Re: Object reference not set to an instance of an object.
« Reply #11 on: 2007-03-11, 04:26:04 AM »
Ok, tried the solution that worked with alpha 1. Doesn't work, doesn't change the error or anything.  :(

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Object reference not set to an instance of an object.
« Reply #12 on: 2007-03-11, 01:06:32 PM »
Does the map editor work?

What versions of d3dx9_30.dll and Microsoft.DirectX.Direct3DX.dll do you have in the directory where SHFL.exe is?

Jam0864

  • Contributor
  • Fanatic
  • **
  • Posts: 744
    • MSN Messenger - marmalade0864@hotmail.com
    • View Profile
    • Jam0864's Content Dump
    • Email
Re: Object reference not set to an instance of an object.
« Reply #13 on: 2007-03-11, 04:48:43 PM »
Map editor works, but when I first open the project I get Object reference not set to an instance of an object, and I have to open it again for it to actually work. There is no file in the same directory as SHFL.exe, there is a folder in there though.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Object reference not set to an instance of an object.
« Reply #14 on: 2007-03-12, 07:00:57 AM »
There should be dozens of files in the same directory as SHFL.exe.  It's just SHFL.exe by itself?  If you copy the DirectX DLLs (including d3dx9_30.dll) from the parent directory into the directory where SHFL.exe is, does it change anything when you run SHFL.exe?