This error never occurred before. Here is my code;
private Process process = null;
private void button5_Click(object sender, EventArgs e)
{
if (null != process)
{
process.Dispose();
}
process = new Process();
process.StartInfo.FileName = "world.exe";
process.StartInfo.Arguments = "";
process.StartInfo.UseShellExecute = false;
process.EnableRaisingEvents = true;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardOutput = true;
process.OutputDataReceived += new DataReceivedEventHandler(process_OutputDataReceived);
process.Exited += new EventHandler(process_Exited);
process.Start();
process.BeginOutputReadLine();
}
private void process_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
}
Here is what I’m getting an error on:
process.OutputDataReceived += new DataReceivedEventHandler(process_OutputDataReceived);
That above is fine until I wrote out;
private void process_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
}
Help would be appreciated. Don’t know how this can be anymore specific than it is.
The only thing that I can think of is that you have a namespace conflict (i.e. there are other classes in your environment that match the names of the classes being used).
Try using explicit namespace declaration: