Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Programming
You last visited: Today at 17:46

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



NullReferenceException

Discussion on NullReferenceException within the CO2 Programming forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Mar 2011
Posts: 165
Received Thanks: 17
Cool NullReferenceException

Alright, This **** Exception annoys me as **** , and I've got No Idea why.
I Believe I'm missing something.. Can somebody remind me what is it?
I know It's un-pro question but ermm... here we go.
iStefan is offline  
Old 03/15/2011, 16:46   #2
 
Ian*'s Avatar
 
elite*gold: 0
Join Date: Nov 2006
Posts: 805
Received Thanks: 464
Declare GUI.

GUI myGUI = new GUI();
Ian* is offline  
Old 03/15/2011, 20:28   #3
 
elite*gold: 0
Join Date: Mar 2011
Posts: 165
Received Thanks: 17
Why "new GUI();" ?
In Program.cs I Have public static iManager GUI; // iManager is the class(form)
iStefan is offline  
Old 03/15/2011, 20:40   #4
 
.Kinshi's Avatar
 
elite*gold: 0
Join Date: Dec 2010
Posts: 341
Received Thanks: 255
Classes need to be initialized.

Read some programming books to get a better grasp.
.Kinshi is offline  
Old 03/15/2011, 21:59   #5
 
elite*gold: 0
Join Date: Mar 2011
Posts: 165
Received Thanks: 17
Quote:
Originally Posted by .Kinshi View Post
Classes need to be initialized.

Read some programming books to get a better grasp.
Yes but Then It Throws "No Source Available" ...
iStefan is offline  
Old 03/17/2011, 09:55   #6
 
Arco.'s Avatar
 
elite*gold: 0
Join Date: Feb 2011
Posts: 335
Received Thanks: 170
Quote:
Originally Posted by iStefan View Post
Yes but Then It Throws "No Source Available" ...
Read some programming books to get a better grasp.
Arco. is offline  
Old 03/17/2011, 10:58   #7
 
elite*gold: 0
Join Date: Jun 2006
Posts: 457
Received Thanks: 67
Quote:
Originally Posted by iStefan View Post
Yes but Then It Throws "No Source Available" ...
Ian already made it so clear for you. Ask yourself, do you see the declaration or even the definition for GUI somewhere in your code?

I'll give you an example, tell me what is wrong.
Code:
int main(){
    printf("%d", [B]var[/B]);
    return 0;
}
shitboi is offline  
Old 03/17/2011, 13:43   #8
 
elite*gold: 0
Join Date: Mar 2011
Posts: 165
Received Thanks: 17
Quote:
Originally Posted by shitboi View Post
Ian already made it so clear for you. Ask yourself, do you see the declaration or even the definition for GUI somewhere in your code?

I'll give you an example, tell me what is wrong.
Code:
int main(){
    printf("%d", [B]var[/B]);
    return 0;
}
Then, var isn't declared. It's the same if i do in C# . Console.WriteLine(string); lmao.
and no need to bold, I'm not so noobish, I just Dunno what am I forgettin'
iStefan is offline  
Old 03/17/2011, 14:39   #9
 
elite*gold: 0
Join Date: Jun 2006
Posts: 457
Received Thanks: 67
in your first post, you have an error msg, GUI not set to an instance of an object. If GUI is not an object, how are you going to call on it's member variable/methods?

What Ian was telling you to do is declare and initialize your GUI. (alright, the syntax will be java, but it's close to C# i think you'll undertand)
Code:
public class test{
    UserDefinedClass GUI = null;

    ...
    ...  //somewhere in the class before GUI has been called, you need to perform
    GUI = new UserDefinedClass();
    ...

    public static void Write(String x){...} // where your error occurred

    public static void WriteLine( ... ){...}
}//end of class defn
if you have an object that you will be assigning reference to, i personally suggest declare it and initialize to null, and you can check if your object is null at any time to make sure things are on the right track
shitboi is offline  
Thanks
1 User
Old 03/17/2011, 17:50   #10
 
Ian*'s Avatar
 
elite*gold: 0
Join Date: Nov 2006
Posts: 805
Received Thanks: 464
well stefan if your methods are static you dont have to initialize it, but in this case I dont think they are if you're just using your gui's properties that visual studios gives you. so you have to initialize it.

Some info on msdn.

Ian* is offline  
Thanks
1 User
Old 03/20/2011, 21:56   #11
 
TomasLT's Avatar
 
elite*gold: 0
Join Date: Nov 2006
Posts: 286
Received Thanks: 38
And start reading what your ide offering u. First troubleshooting tip:

YourClassName GUI = new YourClassName();
TomasLT is offline  
Old 03/21/2011, 16:03   #12
 
elite*gold: 0
Join Date: Mar 2011
Posts: 165
Received Thanks: 17
But I am initializing it when it starts..
Code:
   GUI = new iGUI();
            Application.Run(GUI);
iStefan is offline  
Old 03/21/2011, 17:32   #13
 
elite*gold: 0
Join Date: Jun 2006
Posts: 457
Received Thanks: 67
it's better off that you load your entire code up here so that others can help you.
shitboi is offline  
Reply


Similar Threads Similar Threads
[Visual Basic 2010]System.NullReferenceException
02/13/2011 - .NET Languages - 3 Replies
Hallo Elitepvpers, ich hoffe ich bin hier am richtigen Platz, also ich hab einen Emulator versucht zuverbessern aber es kommt dieser Fehler: System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
[VB 2008] "System.NullReferenceException wurde nicht behandelt"
12/30/2009 - .NET Languages - 9 Replies
Und der Fehler passiert in der Zeile: Sub _Anmelden() WebBrowser1.Document.GetElementById("user&qu ot;).InnerText = TextBox2.Text .......... .......... .......... .......... End Sub
[Help]NullReferenceException
11/23/2008 - CO2 Private Server - 3 Replies
Ok... Well first off, I feel like an idiot fot not knowing what to do here. But I'm completely lost, so if somene could point me in the right direction, I'd appreciate it. Seems this is completely random, sometimes it will occur after 30 minutes, sometimes the server can run for hours without an issue. But occasionally this kicks in, and everything freezes. The code effected is... if (Charr.MyClient.Online) if (MyMath.CanSee(Attacked.LocX,...



All times are GMT +1. The time now is 17:49.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.