mercredi 5 août 2020

How do I use ListViewItem.Text property with obfuscated code

I use .net reactor for obfuscating my c# code. I was not paying attention to this matter when I start writing my current application so now I'm checking my whole code to see if they are working well with obfuscation. I have solved many of this problems but there is 1 I could not understand why it is not working.

My working code without obfuscation is this:

for (int i = 0; i < LoadedLivePresets.Count; i++)
{
    try
    {
        MessageBox.Show("LoadedLivePresets[i] : " + LoadedLivePresets[i].ToString() + "\nDetails : " + LoadedLivePresets[i].PresetDetails.ToString());
        ListViewItem LVI = new ListViewItem();
        MessageBox.Show("LoadedLivePresets[i].PresetName : " + LoadedLivePresets[i].PresetName);
        if (LVI == null)
            MessageBox.Show("LVI NULL");
        MessageBox.Show("LVI.Text : " + LVI.Text);
        LVI.Text = LoadedLivePresets[i].PresetName;
        MessageBox.Show("a1a1a1a1");
        LVI.Tag = LoadedLivePresets[i];
        MessageBox.Show("a2a2a2a2");
        mainForm.lvLiveSources.Items.Add(LVI);
        MessageBox.Show("a3a3a3a3");
    }
    catch (Exception ex)
    {
        MessageBox.Show("ex : " + ex.Message);
        break;
    }
}

I've write down message boxes everywhere to locate the problem. I know my custom list have items I'm sure of it. When I run this code after obfuscation I see my preset details correctly. I see my presetName correctly so far no problem. My code does not show "LVI NULL" so if (LVI == null) comes false I see that LVI.Text is empty so I can reach that property after obfuscation but the problem is this line LVI.Text = LoadedLivePresets[i].PresetName; after this line gets executed my code jumps to exception and says object null.. I checked LVI and I know it's not null and I also checked LoadedLivePresets[i].PresetName and it is also filled.

What am I missing here? both side is not null so why do I get an object null error here? Can someone explain me please?





Aucun commentaire:

Enregistrer un commentaire