Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 安装Windows服务-Setup.exe失败_C#_Visual Studio - Fatal编程技术网

C# 安装Windows服务-Setup.exe失败

C# 安装Windows服务-Setup.exe失败,c#,visual-studio,C#,Visual Studio,我面临着一个奇怪的问题。我创建了我的第一个windows服务,浏览了各种博客和教程。 然后为添加安装程序等创建了安装程序。它在安装时工作正常,通过Visual Studio取消安装,但在部署时失败 Below is a summary of the errors, details of these errors are listed later in the log. * Activation of C:\Users\bhuvint\Documents\Visual Studio 201

我面临着一个奇怪的问题。我创建了我的第一个windows服务,浏览了各种博客和教程。 然后为添加安装程序等创建了安装程序。它在安装时工作正常,通过Visual Studio取消安装,但在部署时失败

Below is a summary of the errors, details of these errors are listed later in the log.
    * Activation of C:\Users\bhuvint\Documents\Visual Studio 2010\Projects\CPNS Library\ServicePackage\CommonPushNotificationWindowsService.application resulted in exception. Following failure messages were detected:
        + You cannot start application CommonPushNotificationWindowsService from this location because it is already installed from a different location.
        + You cannot start application CommonPushNotificationWindowsService from location file:///C:/Users/bhuvint/Documents/Visual%20Studio%202010/Projects/CPNS%20Library/ServicePackage/CommonPushNotificationWindowsService.application it is already installed from location file:///C:/inetpub/wwwroot/ServicePackage/CommonPushNotificationWindowsService.application. You can start it from location file:///C:/inetpub/wwwroot/ServicePackage/CommonPushNotificationWindowsService.application or you can uninstall it and reinstall it from location file:///C:/Users/bhuvint/Documents/Visual%20Studio%202010/Projects/CPNS%20Library/ServicePackage/CommonPushNotificationWindowsService.application.
我已取消安装该服务,并尝试从同一台pc中部署的服务安装该服务以进行测试。但由于上述错误,它失败了。 我觉得我部署windows服务的方式不对。你们能建议如何部署windows服务吗?(我已经浏览了网络。所有人都建议从visual Studio构建和安装它。但如何发布它是我需要的。)


请尽快提供帮助。

可能是您在卸载以前的服务之前构建了安装项目。在这种情况下,您不能使用新的安装程序卸载服务,因为安装程序将不同,并且无法访问已安装的服务

您应该尝试转到项目的早期版本并卸载该服务,以后每次构建安装项目时都应卸载该服务


这种情况在我身上发生过好几次。

在调试模式下运行visual studio,并在服务项目的属性中,转到“生成后事件”命令行中的“生成事件”选项卡,然后添加a-d,这样您就可以在不安装服务的情况下运行服务,它将作为控制台应用程序运行。LocalService帐户在本地计算机上充当非特权用户,并向任何远程服务器提供匿名凭据。请谨慎使用其他帐户,因为它们以更高的权限运行,会增加恶意代码攻击的风险

如果服务应用程序无法正确安装,请检查以确保服务类的ServiceName属性设置为与该服务的安装程序中显示的相同值。为了正确安装服务,两个实例中的值必须相同。 便条

您还可以查看安装日志以获取安装过程的反馈


您还应该检查以确定是否已经安装了另一个同名服务。服务名称必须唯一,安装才能成功

将愚蠢人格化

正如我所说,我正在部署我的服务。因此,这个发布的代码有一个“setup.exe”文件。现在,我已经为windows服务创建了一个安装项目,用于安装、卸载。我不知道(这些话需要勇气!!)安装windows服务需要创建msi文件。因此,当我完成安装项目的文件夹结构时。我偶然发现了.msi文件。于是问题就解决了。主要问题是:

  • 我不知道如何使用安装项目
  • 我把setup.exe与已发布的windows服务和windows服务的设置混淆了

我真的很抱歉从你宝贵的时间中偷走了带宽。感谢大家的宝贵意见。

如果服务确实已停止并卸载,您是否已签入服务?是否已签入服务。msc(通过Windows key+R)您的服务名称是否仍在其中?那你可能得先把它移走。简单的谷歌搜索会告诉你怎么做:)@johnblade和Gerald-是的,我已经做到了。它确实已被卸载。我建议从控制面板上卸载。当我这样做时,它不会重新安装失败,这并不是说我想在不安装的情况下运行它。我想安装它!Jodha-我在我的visual studio中使用它来安装和运行它。它运行完美,没有任何问题,但当我发布它时,它开始显示错误。尝试使用一些旧式代码在行之间编写代码,为您显示或编写消息,以便您可以跟踪进度,然后将其全部删除。