C
C#2y ago
The Joker

✅ System.NullReferenceException: 'Object reference not set to an instance of an object.' C#

hello I'm facing an error I wanted to see if someone can help me this happens only when I try to extract the texture folder, in the others it works fine.
private void extractToolStripMenuItem_Click(object sender, EventArgs e)
{
if (dataHierarchy == null)
{
return;
}
TreeNode selectedNode = packTreeView.SelectedNode;
if (selectedNode == null)
{
return;
}
AskDestinationForm askDestinationForm = new AskDestinationForm();
DialogResult dialogResult = askDestinationForm.ShowDialog();



if (dialogResult == DialogResult.OK)
{
string destinationPath = askDestinationForm.DestinationPath;
string fullPath = selectedNode.FullPath;
fullPath = Pack.Util.Path.FormatPath(fullPath);
FileWriter fileWriter = new FileWriter();

if (selectedNode.Tag is Pack.Structure.File)
{
dataHierarchy.ExtractFileTo(destinationPath, fullPath, fileWriter);
}
else
{
dataHierarchy.ExtractFolderTo(destinationPath, fullPath, fileWriter);
}
}
}
private void extractToolStripMenuItem_Click(object sender, EventArgs e)
{
if (dataHierarchy == null)
{
return;
}
TreeNode selectedNode = packTreeView.SelectedNode;
if (selectedNode == null)
{
return;
}
AskDestinationForm askDestinationForm = new AskDestinationForm();
DialogResult dialogResult = askDestinationForm.ShowDialog();



if (dialogResult == DialogResult.OK)
{
string destinationPath = askDestinationForm.DestinationPath;
string fullPath = selectedNode.FullPath;
fullPath = Pack.Util.Path.FormatPath(fullPath);
FileWriter fileWriter = new FileWriter();

if (selectedNode.Tag is Pack.Structure.File)
{
dataHierarchy.ExtractFileTo(destinationPath, fullPath, fileWriter);
}
else
{
dataHierarchy.ExtractFolderTo(destinationPath, fullPath, fileWriter);
}
}
}
9 Replies
Angius
Angius2y ago
Well, something there is null Start up the debugger and see what it is
The Joker
The JokerOP2y ago
The Joker
The JokerOP2y ago
I couldn't find the error can you help me?
Angius
Angius2y ago
Place some breakpoints The variables in that line are what matters
The Joker
The JokerOP2y ago
Help me please.
JansthcirlU
JansthcirlU2y ago
what's the full exception message? it will mention the thing that's null (when it expected it not to be null)
ero
ero2y ago
dataHierarchy is null
The Joker
The JokerOP2y ago
but this is only transient with this folder, the others work without giving an error
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server