jkh*_*jkh 134 c# windows service windows-services installutil
当我在Visual Studio 2010中创建新的Windows服务时,我收到消息,声明使用InstallUtil和net start来运行该服务.
我尝试了以下步骤:
步骤4的输出
运行事务安装.
开始安装的安装阶段.
请参阅日志文件的内容以获取C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestService\TestService\obj\x86\Debug\TestService.exe程序集的进度.
该文件位于C:\ Users\myusername\Documents\Visual Studio 2010\Projects\Tes tService\TestService\_dj\x86\Debug\TestService.InstallLog.
安装程序集'C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestS ervice\TestService\_dj\x86\Debug\TestService.exe'.
受影响的参数是:
logtoconsole =
logfile = C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestService\T\testService\_dj\x86\Debug\TestService.InstallLog
assemblypath = C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestServ ice\TestService\obj\x86\Debug\TestService.exe
没有具有RunInstallerAttribute.Yes属性的公共安装程序可以在C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestService\TestSe rvice\_ obj\x86\Debug\TestService.exe程序集中找到.
安装阶段成功完成,提交阶段正在开始.
请参阅日志文件的内容以获取C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestService\TestService\obj\x86\Debug\TestService.exe程序集的进度.
该文件位于C:\ Users\myusername\Documents\Visual Studio 2010\Projects\Tes tService\TestService\_dj\x86\Debug\TestService.InstallLog.
提交程序集'C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestS ervice\TestService\_obj\x86\Debug\TestService.exe'.
受影响的参数是:
logtoconsole =
logfile = C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestService\T\testService\_dj\x86\Debug\TestService.InstallLog
assemblypath = C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestServ ice\TestService\obj\x86\Debug\TestService.exe
没有具有RunInstallerAttribute.Yes属性的公共安装程序可以在C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestService\TestSe rvice\_ obj\x86\Debug\TestService.exe程序集中找到.
删除InstallState文件,因为没有安装程序.
提交阶段成功完成.
事务处理安装已完成.
步骤5的输出
服务名称无效.
输入NET HELPMSG 2185即可获得更多帮助.
Mig*_*elo 236
您需要在设计器中打开Service.cs文件,右键单击它并选择菜单选项"添加安装程序".
它不会立即安装......你需要先创建安装程序类.
服务安装程序的一些参考:
很老......但这就是我所说的:
通过这样做,ProjectInstaller.cs
将自动创建一个.然后,您可以双击它,输入设计器,并配置组件:
serviceInstaller1
有服务本身的属性:Description
,DisplayName
,ServiceName
和StartType
是最重要的.
serviceProcessInstaller1
有这个重要的属性:Account
这是服务将运行的帐户.
例如:
this.serviceProcessInstaller1.Account = ServiceAccount.LocalSystem;
Run Code Online (Sandbox Code Playgroud)
Jam*_*are 11
看着:
没有具有RunInstallerAttribute.Yes属性的公共安装程序可以在C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestService\TestSe rvice\_ obj\x86\Debug\TestService.exe程序集中找到.
看起来您的代码中可能没有安装程序类.这是一个继承的类,Installer
它将告诉installutil
您如何将可执行文件安装为服务.
Ps我有自己的小自助安装/可调试Windows服务模板,你可以从中复制代码或使用:Debuggable,自安装Windows服务
这是制作安装程序并摆脱该错误消息的另一种方法.此外,似乎VS2015 express没有"添加安装程序"菜单项.
您只需创建一个类并添加以下代码并添加引用System.Configuration.Install.dll.
using System.Configuration.Install;
using System.ServiceProcess;
using System.ComponentModel;
namespace SAS
{
[RunInstaller(true)]
public class MyProjectInstaller : Installer
{
private ServiceInstaller serviceInstaller1;
private ServiceProcessInstaller processInstaller;
public MyProjectInstaller()
{
// Instantiate installer for process and service.
processInstaller = new ServiceProcessInstaller();
serviceInstaller1 = new ServiceInstaller();
// The service runs under the system account.
processInstaller.Account = ServiceAccount.LocalSystem;
// The service is started manually.
serviceInstaller1.StartType = ServiceStartMode.Manual;
// ServiceName must equal those on ServiceBase derived classes.
serviceInstaller1.ServiceName = "SAS Service";
// Add installer to collection. Order is not important if more than one service.
Installers.Add(serviceInstaller1);
Installers.Add(processInstaller);
}
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
137402 次 |
最近记录: |