Tag: windows services

从Process.Start()调用时,C#app随机挂起

我有一个Windows服务设置来管理自定义.Net任务。 组织是: -Windows Service监视计划并根据需要启动worker .exe。 -Worker .exe(轻量级winform应用程序)使用命令行参数来提取DLL(插件)并运行一些代码。 这已经好几个月了。 我最近将它迁移到Server 2012(从2008 IIRC) – 这可能是不相关的,但很难说。 从迁移后的一段时间开始,我遇到了一个问题,即在由process.start()调用后,worker .exe“启动”,但是没有到达我的代码。 没有错误或任何东西,它似乎在应用程序加载期间冻结。 启动它的服务代码是相当标准的。 // Create a temp folder and copy the executable to it // (so the source exe isn’t always in use and can be swapped out) Process p = new Process(); ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = Path.Combine(temp.Path, […]

从C#启动远程服务

我在C#WinForms应用程序中使用以下代码在远程PC上启动Windows服务 public static List GetServices() { List Services = new List(); ServiceController[] sc = ServiceController.GetServices(Server); foreach (var s in sc) { Services.Add(new Service { Name = s.ServiceName, Running = s.Status == ServiceControllerStatus.Running }); } return Services; } public static bool StartService(string ServiceName) { try { ServiceController sc = new ServiceController(ServiceName, Server); sc.Start(); sc.WaitForStatus(ServiceControllerStatus.Running, new TimeSpan(0, […]

为每个线程分配一个cpu核心

我有一个用.net 4编写的Windows服务,它使用Threads定期做作业。 服务器有超过20个CPU核心。 我在我的Windows服务中创建10个线程。 是否可以为每个线程分配一个cpu核心?

Windows服务已启动,然后使用Topshelf停止

我正在使用Quartz.net,我试图让Quartz服务器在Windows服务中启动。 我创建了一个Windows服务项目并包含了Quartz.net库。 在我的服务类中,我有: protected override void OnStart(string[] args) { try { Host host = HostFactory.New(x => { x.Service(s => { s.SetServiceName(“quartz.server”); s.ConstructUsing(builder => { QuartzServer server = new QuartzServer(); server.Initialize(); return server; }); s.WhenStarted(server => server.Start()); s.WhenPaused(server => server.Pause()); s.WhenContinued(server => server.Resume()); s.WhenStopped(server => server.Stop()); }); x.RunAsLocalService(); //x.RunAs(@”mydomain\mysusername”, “mypassword”); x.SetDescription(Configuration.ServiceDescription); x.SetDisplayName(Configuration.ServiceDisplayName); x.SetServiceName(Configuration.ServiceName); }); host.Run(); } […]

如何自动启动窗口服务

我有一个我用c#开发的窗口服务(vs2008)。 请告诉我如何使其在安装后自动启动,并在系统重新启动时自动启动。 编辑:我正在使用安装和部署项目来安装它。 谢谢

从Windows服务执行Process.Start时拒绝访问

我正在尝试以另一个用户身份从服务运行流程。 Process.Start(applicationPath, params, account, SecureStringPassword, “”); 服务正在“本地系统”帐户下运行。 account参数是一个类似“WORKSTATION6 \ Tester”的字符串。 此用户是Administrators组的成员。 “应用程序路径”是指程序文件,因此每个用户都可以从中读取。 但每次我尝试启动这个过程时,我都会遇到“拒绝访问”的exception。 你有什么建议吗?

将C#控制台应用程序作为Windows服务运行

我有一个基本的C#控制台应用程序,我想作为Windows服务运行。 我使用sc create创建了Windows服务。 这工作正常,我可以在services.msc下看到我的服务。 当我尝试启动此服务时,我收到以下错误: 无法在本地计算机上启动PROJECT服务。 错误1053:服务未及时响应启动或控制请求 我读到这可能是由于服务代码执行时间超过30000毫秒。 因此,我删除了大部分代码,以便几乎没有任何内容被执行..但同样的错误仍然存​​在。 我在这个项目中使用.NET 3.5。 什么会导致这个?

Windows服务正在说明:

我已经厌倦了通过注册表卸载禁用的Windows服务它已从注册表中删除但它仍然显示在Services.msc中 描述:无法读取描述错误代码2

语音识别引擎不是Windows服务中的触发事件

所以我有一个使用system.speech识别引擎实现语音识别的Windows服务。 当我启动服务时,我的语音识别代码运行良好但没有语音事件识别出来。 奇怪的是,如果我运行完全相同的代码,但在控制台或WPF应用程序中,语音识别的事件触发工作正常。 我已经在我的服务进程中附加了一个调试器来检查幕后发生了什么。 似乎语音识别引擎正确加载语法,将其模式设置为连续监听,并正确设置语音识别事件。 没有exception被抛出,所以我不太确定这里有什么问题。 有任何想法吗?

WebApp.Start 方法类型参数

在基于本文使用Owin将我的Windows服务应用程序设置为自托管主机: http://www.asp.net/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api 我使用了WebApp.Start方法的这个重载: WebApp.Start方法(String) 这是我的代码: //(in startup method) _server = WebApp.Start(BaseAddress); public class Startup { // This code configures Web API. The Startup class is specified as a type // parameter in the WebApp.Start method. public void Configuration(IAppBuilder appBuilder) { // Configure Web API for self-host. var config = new HttpConfiguration(); config.Routes.MapHttpRoute(“DefaultApi”, “api/{controller}/{id}”, new { […]