Object reference not set to an instance of an object (1 Viewer)

fripsy

Portal Pro
December 11, 2008
122
63
Grasse
Home Country
France France
Hi All,

I'm pulling my hair out with this one!

I have this declared:
Code:
    [SkinControlAttribute(201)]
    protected GUIButtonControl btnStatus = null;
When I use in my code:

Code:
    btnStatus.Label = "Test";
I get "Object reference not set to an instance of an object" in the Mediaportal.log
I'm sure this has worked before, the only change I can remember is the upgrade from MP1.1.0 to 1.1.1... I think...
This means that "btnStatus" is null at the moment I try to use it, which makes sense as I can't find where it gets binded with the GUIButton with id 201. Should MP bind this for me at the start of my plugin or do I have to do this myself?
If I have to bind it myself, how do I do that?

On another thread I found this
Code:
[SkinControlAttribute(1)]
        protected GUILabelControl lblText = (GUILabelControl)GetControl(1);
But this gives me "Error 1 An object reference is required for the non-static field, method, or property 'MediaPortal.GUI.Library.GUIWindow.GetControl(int)'" in Visual C Express...

Could someone enlighten me on this one?

Thanks,
Fripsy.
 

SilentException

Retired Team Member
  • Premium Supporter
  • October 27, 2008
    2,617
    1,130
    Rijeka, Croatia
    Home Country
    Croatia Croatia
    skin file should have button control with id 201. if it doesn't have it, btnStatus will always be null.

    [SkinControlAttribute(1)]

    Don't use id 1, for plugins always best to use id's 100+ for those small controls..

    buttons should be 2 - 16 but that's your call..
     

    fripsy

    Portal Pro
    December 11, 2008
    122
    63
    Grasse
    Home Country
    France France
    Yes, there is a button in the skinfile with id=201, but...

    I did change the skinfile and that button is now part of an ActionGroup... perhaps that's the problem...
    I will look into that...

    :D
     

    fripsy

    Portal Pro
    December 11, 2008
    122
    63
    Grasse
    Home Country
    France France
    Found it !

    It was due to the skinfile, I'm having trouble to understand how the different controls work together...

    DieBagger
    You're right, for the moment this is just a debug version so I can easily find out what's going on in case that something doesn't work as I expected...

    :D
     

    Users who are viewing this thread

    Top Bottom