c# - 尝试安装用 C# 创建的 Windows 服务应用程序

标签 c# .net windows-services

我正在尝试安装使用以下命令创建的 Windows 服务:

C:\$(MyFiles)\Projects\Win Service\c#\filechecker\filechecker\bin\Debug>InstallU til.exe filechecker.exe

但我收到以下消息:

Running a transacted installation.

Beginning the Install phase of the installation. See the contents of the log file for the C:\$(MyFiles)\Projects\Win Service\c#\filechecker\filechecker\bin\Debug\filechecker.exe assembly's progress. The file is located at C:\$(MyFiles)\Projects\Win Service\c#\filechecker\filechecker\bin\Debug\filechecker.InstallLog.

An exception occurred during the Install phase. System.ArgumentException: Must specify value for source.

The Rollback phase of the installation is beginning. See the contents of the log file for the C:\$(MyFiles)\Projects\Win Service\c#\filechecker\filechecker\bin\Debug\filechecker.exe assembly's progress. The file is located at C:\$(MyFiles)\Projects\Win Service\c#\filechecker\filechecker\bin\Debug\filechecker.InstallLog.

The Rollback phase completed successfully.

The transacted install has completed.

Running a transacted installation.

Beginning the Install phase of the installation. See the contents of the log file for the C:\$(MyFiles)\Projects\Win Service\c#\filechecker\filechecker\bin\Debug\filechecker.exe assembly's progress. The file is located at C:\$(MyFiles)\Projects\Win Service\c#\filechecker\filechecker\bin\Debug\filechecker.InstallLog.

An exception occurred during the Install phase. System.ArgumentException: Must specify value for source.

The Rollback phase of the installation is beginning. See the contents of the log file for the C:\$(MyFiles)\Projects\Win Service\c#\filechecker\filechecker\bin\Debug\filechecker.exe assembly's progress. The file is located at C:\$(MyFiles)\Projects\Win Service\c#\filechecker\filechecker\bin\Debug\filechecker.InstallLog.

The Rollback phase completed successfully.

The transacted install has completed.

我该如何解决这个问题?

最佳答案

A ServiceInstaller always1 创建事件日志源,并将 Source 名称设置为 ServiceName .该错误提示我您没有在您的 ServiceInstaller 实例上设置 ServiceName(尽管我希望出现更好的错误)。


1除非您在实例化后手动迭代其安装程序集合并将其删除。您还必须确保关闭所有自动日志记录和/或手动添加您自己的 EventLogInstaller使用相同的源名称 - 如果您希望来自服务的所有日志记录(包括自动日志记录)都转到应用程序事件日志之外的某个地方其他,这将很有用。

关于c# - 尝试安装用 C# 创建的 Windows 服务应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10446943/

相关文章:

windows - SCardEstablishContext 作为服务挂起

c# - 安排机器唤醒

c# - 尽管安装了 Microsoft.ACE.OLEDB.12.0,但“Microsoft.ACE.OLEDB.12.0”提供程序未在本地计算机上注册

.net - 如果仍然存在对池化 SQL 连接的引用,它们是否会被清除?

.net - 什么是 .NET RIA 服务?

visual-studio-2008 - Visual Studio没有足够的特权来调试此过程。若要调试此过程,Visual Studio必须以管理员身份运行

c# - 复杂的 ASP.NET MVC 绑定(bind)

c# - VS2017 和 VS2019 的主要 Activity 区别

javascript - 使用隐藏输入字段替换数据库中的条目 - Entity Framework

c# - 在 .NET 3.5 中使用 URI 类时保持 url 编码