On Windows 7 when running my program i get an error saying "Object reference is not set to an object".
On Windows 8.1 it runs perfectly fine. I have narrowed it down to a single line causing this:
label14.Text = process["UserName"].ToString();
If i remove this line, it wont give any errors in Windows 7. I can also just do a label14.Text = "Dummytext";
and it works.
Maybe its something to do with the foreach statement but its working just fine with the other variables and the username is working on Windows 8.1.
Any tips?
foreach (ManagementObject process in searcher.Get())
{
//print system info
process.Get();
label6.Text = process["Manufacturer"].ToString() + " " + process["Model"].ToString();
double Ram_Bytes = (Convert.ToDouble(process["TotalPhysicalMemory"]));
label14.Text = process["UserName"].ToString();
label12.Text = "" + (Math.Round(Ram_Bytes / 1073741824, 2)) + " GB";
}