本文介绍了C# InstallUtil/ManagedInstallerClass:为什么键值对不传递到安装程序上下文参数集合中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将服务名称传递到参数列表中,但是当我查看安装程序上下文时,它不存在:
I pass the service name into the argument list, but when I look in the installers context it is not there:
args = new[] { Assembly.GetExecutingAssembly().Location, "/ServiceName=WinService1" };
ManagedInstallerClass.InstallHelper(args);
为什么键值对没有传递到安装程序上下文中?
Why are key value pairs not pass into the installers context?
public override void Install(IDictionary stateSaver)
{
foreach (var param in Context.Parameters)
{
// ServiceName is not available in the Parameters collection
}
}
推荐答案
这是一个很老的话题,但也许有人仍然可以像我一样使用答案,如果它早点在这里:).只有位置之前的参数被传递到安装程序的上下文中.试试这个:
This is quite old thread, but maybe someone still could use the answer like I could have if it was here earlier :).Only parameters before location are being passed into the context for the installer.Try this:
args = new[] { "/ServiceName=WinService1", Assembly.GetExecutingAssembly().Location };
ManagedInstallerClass.InstallHelper(args);
这篇关于C# InstallUtil/ManagedInstallerClass:为什么键值对不传递到安装程序上下文参数集合中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!