- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我希望此时我能在我的电脑上放一枚手榴弹。我很沮丧,因为我不明白为什么我的应用程序无法使用 installUtil 安装。
我刚刚浏览了这个链接:Windows Service Install Ends in Rollback不幸的是,那里的善意建议对我的情况没有帮助,在考虑了 SO 的好人在该链接和其他人上发布的所有答案后,产生了以下错误。
我在网络上寻找过任务并行处理模式的最佳实践,但目前没有任何帮助。我在尝试安装时遇到的最新错误如下:
.exe assembly's progress. The file is located at E:\xxx\MyService\Service_V2.InstallLog. Installing assembly 'E:\xxx\MyService\Service_V2.exe'. Affected parameters are:
logtoconsole = logfile = E:\xxx\MyService\Service_V2.InstallLog
assemblypath = E:\xxx\MyService\Service_V2.exe Installing service Service V2... Service Service V2 has been successfully installed. Creating EventLog source Service V2 in log Application... Installing service Service V2... Creating EventLog source Service V2 in log Application...An exception occurred during the Install phase. System.ComponentModel.Win32Exception: The specified service already exists
The Rollback phase of the installation is beginning. See the contents of the log file for the E:\xxx\MyService\Service_V2 .exe assembly's progress. The file is located at E:\xxx\MyService\Service_V2.InstallLog. Rolling back assembly 'E:\xxx\MyService\Service_V2.exe'. Affected parameters are:
logtoconsole = logfile = E:\xxx\MyService\Service_V2.InstallLog
assemblypath = E:\xxx\MyService\Service_V2.exe Restoring event log to previous state for source Service V2. Restoring event log to previous state for source Service V2. Service Service V2 is being removed from the system... Service Service V2 was successfully removed from the system.The Rollback phase completed successfully.
The transacted install has completed. The installation failed, and the rollback has been performed.
也没有任何内容写入事件日志。
这是我的 OnStart() 方法:
protected override void OnStart(string[] args)
{
var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;
ErrorLogFileName = "Service_V2Errors" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
Service_V2LogFile = "Service_V2Log" + DateTime.Now.ToString("yyyy-MM-dd") + ".log";
ErrorLogPath = ConfigurationManager.AppSettings["Errorpath"].ToString();
CheckBatchRecord = Convert.ToInt32(ConfigurationManager.AppSettings["CheckBatchTime"].ToString());
if (!Directory.Exists(ErrorLogPath))
{
Directory.CreateDirectory(ErrorLogPath);
}
LogMessage("Starting Service " + DateTime.Now.ToString());
_ErrorLog = new StreamWriter(ErrorLogPath + "//" + ErrorLogFileName, true);
_ErrorLog.WriteLine("Error, Location, AdditionalInformation", true);
_ErrorLog.Close();
var t = Task.Run(() => Service_V2Start(), token);
try
{
t.Wait();
}
catch (AggregateException e)
{
LogMessage("Exception messages:");
foreach (var ie in e.InnerExceptions)
LogMessage(ie.GetType().Name + " : " + ie.Message);
LogMessage("\nTask status: " + t.Status);
}
finally
{
tokenSource.Dispose();
}
}
我还为编译的最终安装文件设置了编译模式。
我已经执行了“sc delete Servie V2”,我还检查了服务控制台,但那里没有列出此类服务。
我也试过 InstallUtil.exe -u 命令来卸载,但我仍然得到这个傻瓜错误。我现在该怎么办?
最佳答案
确保您的 Program.cs
文件看起来像这样:
static class Program
{
static void Main()
{
var service = new YourServiceName();
ServiceBase.Run(service);
}
}
在 InitializeComponent()
方法中,确保 ServiceName
属性值与 中的
ServiceName
相同>ProjectInstaller.cs
this.ServiceName = "MyServiceName";//in the YourServiceName partial class
this.myServiceInstaller.ServiceName = "MyServiceName";//in the installer
确保您只有一个安装程序。
在您创建的用于安装和卸载服务的批处理文件中,确保您指向正确的 InstallUtil.exe
。
对于 64 位架构,您可以使用 - C:\Windows\Microsoft.NET\Framework64\v4.0.30319\installutil.exe
对于 32 位架构,您可以使用 - C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe
示例 InstallService.bat 文件:
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\installutil.exe""PathToTheExecutables\MyServiceName.exe"暂停
示例 UninstallService.bat 文件:
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\installutil.exe"/u "PathToTheExecutables\MyServiceName.exe"暂停
关于c# - 为什么我无法安装我的 Windows 服务 - 指定的服务已经存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38220645/
一段时间以来,我一直在做这个反复出现的噩梦(阅读 - 我的应用程序中的错误)。出于某种原因,某个计时器在我停止后继续发送“Elapsed”事件,即使 在事件本身 计时器“承认”已被禁用!检查一下: /
为了找到 2 个 git 分支的共同祖先,需要做的是: git merge-base branch another_branch 好的。但是……如果两个分支都已经 merge 了怎么办?当我在这种情况
关闭。这个问题是opinion-based .它目前不接受答案。 想改进这个问题?更新问题,以便 editing this post 可以用事实和引用来回答它. 1年前关闭。 Improve this
我想要一个相机 View ,可以将图像捕获到本地文件或让用户从本地照片库中选择图像。我想也许有人为此编写了很好的库/代码。也许我可以利用它。已经有好的了吗?谢谢。我只是避免重新发明轮子:) 最佳答案
我从 master 分支创建了一个功能分支。之后有来自功能分支的提交 [F1]。 [F1] -- Feature Branch / [M1]-[M2
我喜欢使用 .NET 进行编程,尤其是 C# 3.0、.NET 3.5 和 WPF。但我特别喜欢的是 Mono .NET 确实与平台无关。 现在我听说了 Mono 中的 Olive 项目。我找不到某种
介绍和搜索 所以我认为我犯了一个严重的错误,我很担心。我已经分析了独立负责人的论坛,我已经接近找到答案,但场景太具体,不适用于我所在的位置。如果您找到可以回答我的问题的特定主题,请链接我。 例如:Ho
我有一个类似于下图的提交图。标记为 * 的提交表示大量提交。 A* | B--------- | | C* D* master 和 cor
我喜欢使用 .NET 进行编程,尤其是 C# 3.0、.NET 3.5 和 WPF。但我特别喜欢的是 Mono .NET 确实与平台无关。 现在我听说了 Mono 中的 Olive 项目。我找不到某种
我们最近接手了一个 .NET 项目,在查看 db 后,我们在某些列中有以下内容: 1)某些列具有诸如" & etc etc 2) 有些有 标签和其他非 html 编码的标签 这些数据
你好,当我导航到应用程序中的另一个页面时出现此错误 我不知道为什么这个错误出现 #0 _AsyncCompleter.complete (dart:async/future_impl.da
我使用以下 C 算法计算数据的 CRC32: #define CRC32_POLYNOM_REVERSED 0xEDB88320 uint32 calcCrc32(uint8* buffer, u
我试图在我的一个测试中断言模型中的字段没有改变。我知道从哲学上这是不正确的,但由于我控制了我需要知道的所有变量,所以我只想检查我的数据库条目是否没有改变。 我愿意接受一个解决方案,该解决方案可以将其转
我是 GitHub 的新手。并通过 Eclipse 使用它我们是两个人在开发一个应用程序。当我在 Git shell 中检查 git status 时,我得到以下状态。 On branch maste
简单代码: std::ifstream file("file.txt"); std::string line; while(getline(file,line)) ; //exhaust file
是的,我又找不到这个 Gradle DSL 方法:'compile()' 问题。 我检查了我有: buildscript { repositories { jcenter()
HTML: articles CSS: #main_menu { float: left; padding-top: 10px; vertical-align: m
我是一名优秀的程序员,十分优秀!