2012-05-17 43 views
0

我在Windows Server 2003上有一个应用程序并将它安装在C#中。 我走上2008年服务器上安装它的应用程序,并安装了一个错误: 我尝试安装它在Windows 2003上运行应用程序C#

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) at System.Configuration.Install.AssemblyInstaller.InitializeFromAssembly()
The inner exception System.ArgumentException was thrown with the following error message: Service name contains invalid characters, is empty, or is too long (max length = 80).. at System.ServiceProcess.ServiceInstaller.set_ServiceName(String value)

的问题是我不明白它是如何工作没有问题。

+0

应用程序的名称是什么? – DOK

回答

1

服务名称包含无效字符,是空的,或者是过长(最大长度= 80)

说,这一切,不是吗?这一切都取决于你正在安装什么以及它如何安装。如果安装程序试图从某处创建具有给定名称的服务,请确保安装程序可以读取“某处”。

至于说here

ServInstall.ServiceName = ConfigurationManager.AppSettings["ServiceName"]; 

这会导致同样的问题对我来说。也许安装程序不能读取app.config?

+0

但我没有检查 –

+1

@BigLeonardo的例外情况并非如此。你正在安装什么应用程序,你是如何安装的(是否有setup.exe或你正在做什么手动操作)它安装了什么(服务,IIS站点等)以及什么时候发生异常?你能发布相关的配置部分吗? – CodeCaster

+0

@BigLeonardo注意这样一个事实,即服务名称不是可执行文件的名称,而是您在安装程序中定义的名称 –

0

内部异常System.ArgumentException被抛出与 以下错误消息:服务名称包含无效字符,是 空,或者太长(最大长度= 80)..在 System.ServiceProcess .ServiceInstaller.set_ServiceName(String value)

看看服务名称是否有效,还请检查您是否有权通过您的应用程序创建服务。

相关问题