C# InstallUtil/ManagedInstallerClass:为什么键值对没有传递到安装程序上下文参数集合中?
我将服务名称传递到参数列表中,但是当我查看安装程序上下文时,它不存在:
args = new[] { Assembly.GetExecutingAssembly().Location, "/ServiceName=WinService1" };
ManagedInstallerClass.InstallHelper(args);
为什么键值对不传递到安装程序上下文中?
public override void Install(IDictionary stateSaver)
{
foreach (var param in Context.Parameters)
{
// ServiceName is not available in the Parameters collection
}
}
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
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个相当古老的线程,但也许有人仍然可以使用答案,就像我可以使用的答案一样,如果它早些时候在这里:)。
只有位置之前的参数才会被传递到安装程序的上下文中。
试试这个:
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:
试试这个代码:
Try this code: