C
C#17mo 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
Angius17mo ago
Well, something there is null Start up the debugger and see what it is
The Joker
The Joker17mo ago
The Joker
The Joker17mo ago
I couldn't find the error can you help me?
Angius
Angius17mo ago
Place some breakpoints The variables in that line are what matters
The Joker
The Joker17mo ago
Help me please.
JansthcirlU
JansthcirlU17mo ago
what's the full exception message? it will mention the thing that's null (when it expected it not to be null)
ero
ero17mo ago
dataHierarchy is null
The Joker
The Joker17mo ago
but this is only transient with this folder, the others work without giving an error
Accord
Accord17mo 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.