0

サービス名を引数リストに渡しますが、インストーラーのコンテキストを見るとそこにはありません:

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
    } 
}
4

2 に答える 2

5

これはかなり古いスレッドですが、以前にここにあった場合と同じように、誰かがまだ答えを使用できるかもしれません:)。場所の前のパラメーターのみがインストーラーのコンテキストに渡されます。これを試して:

args = new[] { "/ServiceName=WinService1", Assembly.GetExecutingAssembly().Location };
ManagedInstallerClass.InstallHelper(args);
于 2013-10-16T10:22:58.600 に答える
0

このコードを試してください:

IDictionary dictionary = new Dictionary<string, IEnumerable<string>>();
dictionary.Add(Assembly.GetExecutingAssembly().Location, 
               new string [] {"/ServiceName=WinService1"});
ManagedInstallerClass.InstallHelper(dictionary);
于 2011-05-27T16:31:31.147 に答える