【发布时间】:2013-11-05 09:09:39
【问题描述】:
我一直在寻找答案,但没有找到答案,所以我发布了这个。
我已经构建了一个 Windows 服务,我必须将它安装在客户服务器上。我已经在本地成功地测试了它(通过 Visual Studio cmd 提示安装 installutil.exe)。现在,我正在尝试使用 Wix Toolset 3.7 进行安装。该服务安装并启动正常,但我没有从中得到任何东西。它什么都不做,没有调用数据库(应该如此),什么也没有。它在那里,它活着,但它不做蹲下。有点懒惰的服务。
我不知道我做错了什么。这是我的 Wix 代码:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="NeoSrvKrka" Language="1033" Version="1.0.0.0" Manufacturer="Neolab d.o.o." UpgradeCode="04f2a5be-92e1-4c53-8e45-7ae2740a9098">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Manufacturer="Neolab d.o.o." />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="NeoSrvKrka" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="NeoSrvKrka" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<Component Id="ProductComponent">
<File Id="NeoSrvExe" Name="SalusWindowsService.exe" Source="..\SalusWindowsService\bin\Debug\SalusWindowsService.exe" Vital="yes" KeyPath="yes"></File>
<File Id="NeoSrvExeConfig" Name="SalusWindowsService.exe.config" Source="..\SalusWindowsService\bin\Debug\SalusWindowsService.exe.config" Vital="yes" KeyPath="no"></File>
<ServiceInstall
Id="ServiceInstaller"
Type="ownProcess"
Vital="yes"
Name="SalusKrkaService"
DisplayName="Salus Krka Service"
Description="Windows service za prenos narocil iz Salusa v Krko"
Start="auto"
Account="LocalSystem"
ErrorControl="ignore"
Interactive="no"
>
</ServiceInstall>
<ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="SalusKrkaService" Wait="yes" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
在我的应用程序中,我还创建了 ProjectInstaller 文件以及它周围的所有魔法(也许我不应该将它与 wix 一起使用?)。哦,我正在使用 Visual Studio 2012、.NET 4.5、c#、windows 7(将在生产中使用 windows server 2012)。
我正在添加一些应该执行的代码:
namespace SalusWindowsService
{ 公共部分类 Krka:ServiceBase { 公共克尔卡() { 初始化组件(); }
protected override void OnStart(string[] args)
{
try
{
Timer timer = new Timer();
timer.Interval = 3000; //5 minut
timer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
timer.Enabled = true;
GC.KeepAlive(timer);
}
catch (Exception exc)
{
//NeoException.Handle(exc);
}
}
private static void OnTimedEvent(object source, ElapsedEventArgs e)
{ //do something, but it is not doing anything...}}}
我在代码中甚至在服务的主函数(它只是初始化基类)中设置了一些断点,但我从来没有到达那里。
【问题讨论】:
-
检查 Windows 事件查看器是否存在 dbconnection 失败、安全失败等错误。
-
抱歉,已经这样做了,但是没有任何问题,没有错误,没有安全故障或类似的事情。我还在调试模式下附加了进程,但没有任何反应,好像服务从未启动,虽然我可以在服务列表中看到它,我可以停止它,重新启动它等等。
-
它应该做什么?您是否知道必须运行一段简单的代码?
-
我添加了一些应该执行的代码。但我认为问题不在于代码。当我使用 installutil.exe 安装代码时,代码本身运行良好。我看起来 wix 并没有真正安装任何东西或没有正确安装?我还添加了对 WIX 设置项目的应用程序参考。我在应用程序项目中也有更多的 dll。我应该将它们添加到我的 exe 和配置文件之类的 wix 代码中吗?
-
这个问题在问题中得到了回答。
标签: c# visual-studio-2012 windows-services wix wix3.7