控制台应用程序中的“名称'进程'在当前上下文中不存在”错误

时间:2015-01-31 01:07:49

标签: c# process compiler-errors xamarin-studio

我试图使用Process类,但每次我都会给我编译错误

  

名称'流程'在当前上下文中不存在

我已经在代码顶部添加了using System.Diagnostics;,但我仍然遇到此错误。自动完成甚至不会识别该课程。

听到的是代码。我只包含Main method,因为其余代码与错误无关。

using System;
using System.Reflection;
using System.Collections.Generic;
using System.IO;
using System.Diagnostics;
public class MainClass
{
    static void Main()
    {
        AIRuntime adam = new AIRuntime("Adam", false);
        adam.AIUpdate();
        Process.Start(adam.directory);  //adam.directory is just a string
    }
}

如果重要的话,我的IDE是Xamarin Studio。

1 个答案:

答案 0 :(得分:7)

网络搜索和尝试后,我发现了问题。

要解决此问题,我会在项目选项中手动添加对System的引用,而不是仅键入using System;。我还需要将using System.Diagnostics;保留在顶部。它全部在下面的图片中

enter image description here

感谢各位帮忙