I have an interesting problem here, as this bug only appears when there is NO Debug statements preceding the access to FileName.
//make a new process
process = new Process();
process.StartInfo.FileName = executable;
process.Start();
Debug.Print((process.MainModule == null).ToString());
Debug.Print(process.MainModule.FileName);
path = process.MainModule.FileName;
process.Kill();
I essentially just want to access the file path of the executable that I hand to it (ex: chrome.exe, so it finds the path and I can later get the icon, etc.). However, without the Debug statements, the code simply doesn't work, and spits back a NullReferenceException for
path = process.MainModule.FileName
I'm positive this isn't the most effective way to just get the file path of an executable, and if anyone has another approach to this or has any idea as to why this is happening, it would be much appreciated.