2011-05-31 26 views
6

我在安装Windows服务时遇到了一些问题。使用InstallUtil.exe安装Windows服务时出错

我跟着马特的指示建立我的服务: Easiest language for creating a Windows service

的ServiceAccount被设置为用户,虽然我曾尝试本地服务,本地系统和网络服务。

我的Windows服务的目的是为我的WCF服务创建一个主机。我运行Windows 7 64位教授

我跑在PowerShell中以下w /管理员Privelages:

PS C:\windows\Microsoft.NET\Framework64\v2.0.50727> ./installutil "H:\<omitted>\Host Windows Service.exe" 

我收到以下错误:

Microsoft (R) .NET Framework Installation utility Version 2.0.50727.4927 
Copyright (c) Microsoft Corporation. All rights reserved. 

Running a transacted installation. 

Beginning the Install phase of the installation. 
See the contents of the log file for the H:\<omitted>\Host Windows Service.exe assembly's progress. 
The file is located at H:\<omitted>\Host Windows Service.InstallLog. 
Installing assembly 'H:\<omitted>\Host Windows Service.exe'. 
Affected parameters are: 
    assemblypath = H:\<omitted>\Host Windows Service.exe 
    logfile = H:\<omitted>\Host Windows S 
ervice.InstallLog 
    logtoconsole = 
Unable to create an instance of the Host_Windows_Service.ProjectInstaller installer type. 
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. 
The inner exception System.Security.SecurityException was thrown with the following error message: That assembly does no 
t allow partially trusted callers.. 

An exception occurred during the Install phase. 
System.InvalidOperationException: Unable to create an instance of the Host_Windows_Service.ProjectInstaller installer ty 
pe. 
The inner exception System.Reflection.TargetInvocationException was thrown with the following error message: Exception h 
as been thrown by the target of an invocation.. 
The inner exception System.Security.SecurityException was thrown with the following error message: That assembly does no 
t allow partially trusted callers.. 

The Rollback phase of the installation is beginning. 
See the contents of the log file for the H:\<omitted>\Host Windows Service.exe assembly's progress. 
The file is located at H:\<omitted>\Host 
Windows Service.InstallLog. 
Rolling back assembly 'H:\<omitted>\Host Windows Service.exe'. 
Affected parameters are: 
    assemblypath = H:\<omitted>\Host Windows Service.exe 
    logfile = H:\<omitted>\Host Windows Service.InstallLog 
    logtoconsole = 
Unable to create an instance of the Host_Windows_Service.ProjectInstaller installer type. 
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. 
The inner exception System.Security.SecurityException was thrown with the following error message: That assembly does no 
t allow partially trusted callers.. 
An exception occurred during the Rollback phase of the System.Configuration.Install.AssemblyInstaller installer. 
System.InvalidOperationException: Unable to create an instance of the Host_Windows_Service.ProjectInstaller installer ty 
pe. 
The inner exception System.Reflection.TargetInvocationException was thrown with the following error message: Exception h 
as been thrown by the target of an invocation.. 
The inner exception System.Security.SecurityException was thrown with the following error message: That assembly does no 
t allow partially trusted callers.. 
An exception occurred during the Rollback phase of the installation. This exception will be ignored and the rollback wil 
l continue. However, the machine might not fully revert to its initial state after the rollback is complete. 

The Rollback phase completed successfully. 

The transacted install has completed. 
The installation failed, and the rollback has been performed. 

我甚至尝试禁用UAC完全没有运气。如果您需要更多信息,请告诉我。

我很想用Matt的方法来安装Windows服务:How to make a .NET Windows Service start right after the installation?。虽然,我担心我会遇到类似的问题。

感谢

+0

写这个问题的方式,这听起来有点偏离编程的话题。没有投票给它关闭,因为它涉及到前一个SO问题的一个例子,但是试着在问题和标题中强调.NET,C#等。 – 2011-05-31 19:33:08

+0

谢谢@AJ我希望有人会对抛出的异常有一些经验,并且可以让我知道我是否在做一些愚蠢的事情。 – 2011-05-31 19:35:13

+0

@Ryan R,内部异常表示它的安全性,即权限问题。我不是这方面的专家,但是这里有一个看似相关的链接。 http://msdn.microsoft.com/en-us/library/8skskf63.aspx – 2011-05-31 19:52:27

回答

3

尝试移动服务及其依赖于C:驱动器,并再次尝试,尤其是H:是一个网络驱动器。

+0

我同意。当试图在网络共享上使用InstallUtil和程序集时,我遇到了同样的问题。我必须将其设置为本地驱动器参考,而不是UNC参考。 – 2012-04-03 16:14:45