0

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?

Shino Lex
  • 487
  • 6
  • 22
  • `MessageBox.Show("LVI.Text : " + LVI.Text);` is showing empty, because you are calling it before you add something – TheGeneral Aug 05 '20 at 07:03
  • I know thats why I wrote it before I fill it. I wanted to see and be sure that LVI is not null and I could reach its "Text" property. I'm sure now that my LVI is not null and Text property is available for me to get or set – Shino Lex Aug 05 '20 at 07:06
  • 1
    If an original code works well, but obfuscated code doesn't work the same way, then there is a bug in the obfuscator. Contact their support, or choose another solution: https://stackoverflow.com/a/60054/1480104 – Artem Razin Aug 05 '20 at 14:17
  • I contact the creator of tool(.net reactor) and they said there might a bug and asked for time to solve it, the problem was not about obfuscation, the "Hide Method Calls" option is causing this problem. I've closed that option for now. – Shino Lex Sep 01 '20 at 07:27

0 Answers0