NullReferenceException

NullReferenceException

Postby joppiesaus » 22 Jun 2013, 14:15

Hi, I was coding a new plugin and I was testing my EventHandlerExtensions(see my signature) and I got a reference exception!
here is the code:
Spoiler:

Knipsel.PNG
some extra info about the error
Knipsel.PNG (6.97 KiB) Viewed 232 times

Thanks for the help!
joppiesaus
 
Posts: 379
Joined: 20 Aug 2012, 07:28
Location: in a obsedian house, with glass in it so i can see the lava!

Re: NullReferenceException

Postby lucasds12 » 22 Jun 2013, 14:21

Hmm, I think your either using the EventHandlerExtensions incorrectly or that I don't know a single fact about coding so I can't even find out what's wrong.
-Lucas
There is only one thing I do in life, that's contributing here.
lucasds12
 
Posts: 334
Joined: 17 Apr 2013, 16:17
Location: In the deep caves.

Re: NullReferenceException

Postby HETAL » 22 Jun 2013, 14:24

I am not good with plugins but it seems like from the errors you need to check the eventhandlerextension
YOU HAVENT SEEN THE LAST OF ME ISMELLIKE
HETAL
 
Posts: 397
Joined: 24 May 2013, 12:10

Re: NullReferenceException

Postby ismellike » 22 Jun 2013, 14:30

The button,textbox, and checkbox are still undefined.
The initialize is trying to use them before they are available.
What a beast...
User avatar
ismellike
Coder
 
Posts: 731
Joined: 31 Oct 2012, 04:04
Location: Kansas

Re: NullReferenceException

Postby joppiesaus » 22 Jun 2013, 15:42

ismellike wrote:The button,textbox, and checkbox are still undefined.
The initialize is trying to use them before they are available.


Thanks Ismelike! It worked!
Now I have another problem, the loop to check if the button is clicked(not in the class)
Because the loop in the class will just say true. But there isn't any working loop that check if it is true.
joppiesaus
 
Posts: 379
Joined: 20 Aug 2012, 07:28
Location: in a obsedian house, with glass in it so i can see the lava!

Re: NullReferenceException

Postby ismellike » 22 Jun 2013, 16:38

You can try using a timer for a loop.

Code: Select all
using System.Windows.Forms

        public override void Initialize()
        {
            System.Windows.Forms.Timer timer = new Timer();
            timer.Tick += new EventHandler(timer_Tick);
            timer.Interval = 100;//milliseconds
            timer.Start();
        }

        public void timer_Tick(object sender, EventArgs e)
        {
            try
            {
                EventHandlerExtension.ClickEvent button = new EventHandlerExtension.ClickEvent(gui.button1);
                if (button.buttonClicked)
                {
                    addBot();
                    button.buttonClicked = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }


I'm not sure I quite understood the question :o
What a beast...
User avatar
ismellike
Coder
 
Posts: 731
Joined: 31 Oct 2012, 04:04
Location: Kansas

Re: NullReferenceException

Postby joppiesaus » 22 Jun 2013, 18:41

ismellike wrote:You can try using a timer for a loop.

Code: Select all
using System.Windows.Forms

        public override void Initialize()
        {
            System.Windows.Forms.Timer timer = new Timer();
            timer.Tick += new EventHandler(timer_Tick);
            timer.Interval = 100;//milliseconds
            timer.Start();
        }

        public void timer_Tick(object sender, EventArgs e)
        {
            try
            {
                EventHandlerExtension.ClickEvent button = new EventHandlerExtension.ClickEvent(gui.button1);
                if (button.buttonClicked)
                {
                    addBot();
                    button.buttonClicked = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }


I'm not sure I quite understood the question :o


Yeah you understood it. I actually coded this timer almost the same before I read this, turned out to be not efficient, started over. Thanks anyways :)
joppiesaus
 
Posts: 379
Joined: 20 Aug 2012, 07:28
Location: in a obsedian house, with glass in it so i can see the lava!


Return to Help in Coding

Who is online

Users browsing this forum: No registered users and 6 guests