English 中文(简体)
找不到哪类或名称的航天员(如果你没有指示或大会参考资料?)
原标题:The type or namespace name ServiceController could not be found (are you missing a using directive or an assembly reference?)

我写过了一个Windows Service,我有一个行政小组,我可以把这一服务从一个网页上调。 为了做到这一点,我正在使用一个数据库。 因此,基本上,我所做的是,我改变了b的价值,而这项服务就是说,它改变了执行时间。

我的问题是,在我的发展服务器中,一切工作都是出色的。 当我安装我的服务并将网页上上上载到生产服务器时,我正在发现这一错误。

无法找到哪类或称号的S-Controller(如果你没有指示或大会参考资料?)

它正在我的网页上留下这一错误。 我检查了它的安装并做了一些细微的工作,但当我试图上下班时,我会发现这一例外。 在我的项目中,我看到我有<编码>使用系统。 服务程序;在顶端加上,在我制定解决办法时,这一批号参考错误就显示出来。 在设计师中,似乎已经进口:

<@ Import Namespace="System.ServiceProcess">; What might be the problem? Can it be a 32-bit / 64-bit issue? ( I know it doesnt make sense but any help will be appreciated)

ServiceController agService = new ServiceController("Buddy Service");
while (agService.Status == ServiceControllerStatus.Running)
{                   
  lblServiceStatus.Text = "Running";
  lblServiceStatus.ForeColor = Color.LimeGreen;
  btnStopService.Enabled = true;
  btnStartService.Enabled = false;
  break;
}

It throws the exception on the line

ServiceController agService = new ServiceController("Buddy Service");

I have made sure that "Buddy Service" is in the Services list and it does.

最佳回答

It sounds like you have the assembly referenced correctly.

修改这一条:

ServiceController agService = new ServiceController("Buddy Service");

为此:

var agService = new System.ServiceProcess.ServiceController("Buddy Service");

如果这项工作可行,你也可能需要改变这一行:

while (agService.Status == ServiceControllerStatus.Running)

为此:

while (agService.Status == System.ServiceProcess.ServiceControllerStatus.Running)
问题回答

be sure you added the System.ServiceProcess in your references list than the user list:

“Example”/





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签