C
C#9mo ago
dismal

How do I fix 'Object reference not set to an instance of an object.'?

I have an app that you can change the background in. The background of a panel in Form1 is set with this function:
public void SetPanelBackgroundImage(Image backgroundImage)
{
Form1.back_panel.BackgroundImage = backgroundImage;
}
public void SetPanelBackgroundImage(Image backgroundImage)
{
Form1.back_panel.BackgroundImage = backgroundImage;
}
back_panel is set to Public so it can be accessed from my other form (UC_tab_theme.cs) and Form1 is instanced from
Form1 Form1;
Form1 Form1;
The parameter that I pass into my SetPanelBackgroundImage() function is Properties.Resources.blob_scene_haikei which is a valid path to the image. I get error:
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=ProtoSploit
StackTrace:
at ProtoSploit.res.UCs.UC_tab_theme.SetPanelBackgroundImage(Image backgroundImage)
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=ProtoSploit
StackTrace:
at ProtoSploit.res.UCs.UC_tab_theme.SetPanelBackgroundImage(Image backgroundImage)
I'm new and I don't particularly understand c# yet, so I hope one of you can help.
2 Replies
Pobiega
Pobiega9mo ago
you are trying to access a property/method on something that has a null value it's likely either Form1 or back_panel here I'm curious what kind or program "ProtoSploit" is thou, if you could tell me more about what it does?
dismal
dismal9mo ago
its a small dbg app with proto meaning prototype and sploit, exploiting the win32 api to hook into apps