下面的代码在一个简单的演示中运行,但在我的实际项目中没有编译。
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string AgentName = "Test";
string SERVICE_NAME = "Agent";
ServiceController sc = new ServiceController(AgentName);
ServiceControllerStatus status = sc.Status;
Debug.WriteLine(String.Format("Service {0} {1}", SERVICE_NAME,
// compile error this next line:
Enum.GetName(typeof(ServiceControllerStatus), sc.Status)));
}
}
}
错误消息是:
命名空间中不存在类型或命名空间名称“GetName”
'UtilLibrary.枚举'
UtilLibrary
像这样的事情
UtilityLibrary
,编译得很好。好像会和你有冲突
GetName()
但事实并非如此,在搜索中什么也找不到。
p、 我是新来的。也可以添加点来改变名称空间
UtilLibrary.General
,仍然无法修复错误。