尝试从控制台应用程序创建Windows服务,但它不会安装

时间:2013-09-09 21:02:26

标签: c# windows windows-services

我正在尝试使用microsoft的这个教程.... here

我无法安装installutil ...我不断收到“删除InstallState文件,因为没有安装程序。”

exe中有一个安装程序....这里是安装程序,因为它存在于我的代码中:

        // Provide the ProjectInstaller class which allows 
    // the service to be installed by the Installutil.exe tool
    [RunInstaller(true)]
    public class ProjectInstaller : Installer
    {
        private ServiceProcessInstaller process;
        private ServiceInstaller service;

        public ProjectInstaller()
        {
            process = new ServiceProcessInstaller();
            process.Account = ServiceAccount.LocalSystem;
            service = new ServiceInstaller();
            service.ServiceName = "WCFWindowsServiceSample";
            Installers.Add(process);
            Installers.Add(service);
        }
    }
}

此时这非常烦人。如果有人可以看一下非常简单的微软文章,我将不胜感激。有了安装程序,我不知道为什么installutil会找不到它。

是的我作为管理员运行visual studio命令提示符来执行此操作。

1 个答案:

答案 0 :(得分:2)

奇怪的是要解决这个问题,我需要将安装程序移动到新的cs文件,并且这样做了。我只是创建了一个新的类文件,并将完全相同的类从主文件移动到另一个文件并安装好了。这对我来说没有意义,但对于那些可能感兴趣的人来说,这是一种解决方法。

相关问题