我正在尝试安装使用以下命令创建的 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/