Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.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 server 2008上安装.Net服务_C#_Windows_Service_Installation - Fatal编程技术网

C# 在windows server 2008上安装.Net服务

C# 在windows server 2008上安装.Net服务,c#,windows,service,installation,C#,Windows,Service,Installation,我有以下问题,, 我希望在系统上安装我的应用程序作为服务。 我的类继承自System.Configuration.Install.Installer。当我在该类的构造函数中尝试获取Context属性的参数时,问题开始出现,然后我得到以下异常: 无法创建(从安装程序继承的我的类名)安装程序类型的实例 当我打印出Context属性时,我在构造函数中看到它为null(并且在尝试访问Context属性时抛出异常)。 同样的代码在2003年运行良好,安装成功,但在这里失败。如果可能,将代码从构造函数移动到

我有以下问题,, 我希望在系统上安装我的应用程序作为服务。 我的类继承自System.Configuration.Install.Installer。当我在该类的构造函数中尝试获取Context属性的参数时,问题开始出现,然后我得到以下异常:

无法创建(从安装程序继承的我的类名)安装程序类型的实例

当我打印出Context属性时,我在构造函数中看到它为null(并且在尝试访问Context属性时抛出异常)。

同样的代码在2003年运行良好,安装成功,但在这里失败。

如果可能,将代码从构造函数移动到安装。安装程序的常见用法是:

using ( TransactedInstaller transactedInstaller = new TransactedInstaller() )
{
    transactedInstaller.Installers.Add(myInstaller);
    transactedInstaller.Context = new InstallContext(null, null);
    transactedInstaller.Install(new System.Collections.Hashtable());
}
这就是为什么
Context
在构造函数中为空