private static void InstallService(
TargetFramework targetFramework,
string binaryPathName)
{
string installUtilPath = null;
switch (targetFramework)
{
case TargetFramework.Net20:
case TargetFramework.Net35:
installUtilPath = s_installUtil20Path;
break;
case TargetFramework.Net40:
case TargetFramework.Net45:
installUtilPath = s_installUtil40Path;
break;
}
Process p = CreateCustomProcess(
installUtilPath,
string.Format(
"\"{0}\"",
binaryPathName),
true);
p.Start();
p.WaitForExit();
if (p.ExitCode == 0)
{
return;
}
string message = string.Format(
Resources.ServiceInstallError,
binaryPathName);
throw new InvalidOperationException(message);
}