I have a windows form application which does 1 thing: launch Edge, the kill the process:
private void Form1_Load(object sender, EventArgs e)
{
try
{
Process edgeProc = new Process();
edgeProc = Process.Start("microsoft-edge:.exe");
edgeProc.Kill();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + Environment.NewLine + Environment.NewLine + ex.StackTrace);
}
}
I don't have a machine with Win10 + Edge to debug this code on, but I indirectly have access to a Windows 10 VM. I build my application and run the exe on that VM, Edge launches but then an exception is thrown:
Object reference not set to an instance of an object.
at EdgeLauncher.Form1.Form1_Load(Object sender, EventArgs e)
I understand what a NullReferenceException
is and am plenty familiar with this question.
MSDN says:
A new Process that is associated with the process resource, or null if no process resource is started.
Edge is being launched, so edgeProcess
shouldn't be null
. So why am I getting this error?