2012-06-06 31 views
0

尝试将服务安装到当前在.Net Framework 2.0下运行的服务器上。当我从安装项目运行.MSI文件时,所有内容都被复制过,但是当我在SMC下进行检查时,服务不在那里。此外,当我尝试使用InstallUtil安装该服务时,系统提示您在程序集中找不到具有RunInstallerAtrribute.Yes属性的公共安装程序。当我检查我的ProjectInstaller.cs时,一切看起来都不错。另外,我可以在我的电脑上安装,我在服务器和我的盒子上都拥有管理员权限。服务不会在服务器上部署

这里是ProjectInstaller.cs文件

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Configuration.Install; 


namespace MyService 
{ 
    [RunInstaller(true)] 
    public partial class ProjectInstaller : Installer 
    { 
     public ProjectInstaller() 
     { 
      InitializeComponent(); 
     } 
    } 
} 

编辑:服务器正在运行Windows 2003 R2服务包两项。 个人计算机运行的是Windows 7和视觉工作室2010

+0

约** **哪个服务器可能是好的(只有半打信息左右)以及您尝试运行安装的帐户。 –

回答

1

下面是一些代码,安装的服务的示例:

[RunInstaller(true)] 
public class InstallMyService : Installer 
{ 
    public InstallMyService() 
    { 
     var svc = new ServiceInstaller(); 

     svc.ServiceName = "MyService"; 
     svc.Description = "This is a service"; 
     svc.DisplayName = "My Service"; 
     svc.StartType = ServiceStartMode.Automatic; 

     var svcContext = new ServiceProcessInstaller(); 
     svcContext.Account = ServiceAccount.LocalSystem; 

     Installers.Add(svc); 
     Installers.Add(svcContext); 
    } 
} 
+0

这样做。但是,当您为服务创建安装程序时,它与VS2010 auto生成的内容有什么区别? –

+0

我不能说。上面的技术最初是从MSDN网站上的示例代码复制的,尽管我没有参考。 –