本文整理汇总了C#中System.Configuration.Install.AssemblyInstaller.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# AssemblyInstaller.Dispose方法的具体用法?C# AssemblyInstaller.Dispose怎么用?C# AssemblyInstaller.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Configuration.Install.AssemblyInstaller
的用法示例。
在下文中一共展示了AssemblyInstaller.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InstallService
/// <summary>
/// 安装服务:
/// </summary>
/// <param name="filepath"></param>
public void InstallService(string filepath)
{
try
{
string serviceName = GetServiceName(filepath);
ServiceController service = new ServiceController(serviceName);
if (!ServiceIsExisted(serviceName))
{
//Install Service
AssemblyInstaller myAssemblyInstaller = new AssemblyInstaller() { UseNewContext = true, Path = filepath };
myAssemblyInstaller.Install(new Hashtable());
myAssemblyInstaller.Commit(new Hashtable());
myAssemblyInstaller.Dispose();
//--Start Service
service.Start();
}
else
{
if (service.Status != ServiceControllerStatus.Running && service.Status != ServiceControllerStatus.StartPending)
{
service.Start();
}
}
}
catch (Exception ex)
{
throw new Exception("installServiceError/n" + ex.Message);
}
}
示例2: InstallService
/// <summary>
/// 安装Windows服务
/// </summary>
/// <param name="stateSaver">状态集合</param>
/// <param name="filepath">程序文件路径</param>
public static void InstallService(IDictionary stateSaver, String filepath)
{
AssemblyInstaller AssemblyInstaller1 = new AssemblyInstaller();
AssemblyInstaller1.UseNewContext = true;
AssemblyInstaller1.Path = filepath;
AssemblyInstaller1.Install(stateSaver);
AssemblyInstaller1.Commit(stateSaver);
AssemblyInstaller1.Dispose();
}
示例3: UnInstallService
/// <summary>
/// 卸载windows服务
/// </summary>
/// <param name="filepath">获取或设置要安装的程序集的路径。</param>
public static void UnInstallService(String serviceName, string filepath)
{
if (ServiceIsExisted(serviceName))
{
AssemblyInstaller myAssemblyInstaller = new AssemblyInstaller();
myAssemblyInstaller.UseNewContext = true;
myAssemblyInstaller.Path = filepath;
myAssemblyInstaller.Uninstall(null);
myAssemblyInstaller.Dispose();
}
}
示例4: InstallService
public static void InstallService()
{
string exePath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
string strDir = System.IO.Path.GetDirectoryName(exePath);
string filepath = strDir + "\\MPlayerWWService.exe";
IDictionary mSavedState = new Hashtable();
AssemblyInstaller myAssemblyInstaller = new AssemblyInstaller();
myAssemblyInstaller.UseNewContext = true;
myAssemblyInstaller.Path = filepath;
myAssemblyInstaller.Install(mSavedState);
myAssemblyInstaller.Commit(mSavedState);
myAssemblyInstaller.Dispose();
}
示例5: UnInstallmyService
/// <summary>
/// 卸载Windows服务
/// </summary>
/// <param name="filepath">程序文件路径</param>
public static void UnInstallmyService(IDictionary stateSaver,string filepath)
{
try
{
AssemblyInstaller AssemblyInstaller1 = new AssemblyInstaller();
AssemblyInstaller1.UseNewContext = true;
AssemblyInstaller1.Path = filepath;
AssemblyInstaller1.Uninstall(stateSaver);
AssemblyInstaller1.Dispose();
}
catch (Exception exp)
{
MessageBox.Show(exp.Message.ToString());
}
}
示例6: UnInstallService
/// <summary>
/// 卸载windows服务:
/// </summary>
/// <param name="filepath"></param>
public void UnInstallService(string filepath)
{
try
{
string serviceName = GetServiceName(filepath);
if (ServiceIsExisted(serviceName))
{
//UnInstall Service
AssemblyInstaller myAssemblyInstaller = new AssemblyInstaller() { UseNewContext = true, Path = filepath };
myAssemblyInstaller.Uninstall(null);
myAssemblyInstaller.Dispose();
}
}
catch (Exception ex)
{
throw new Exception("unInstallServiceError/n" + ex.Message);
}
}
示例7: Install
static void Install(bool undo, string[] args)
{
try
{
Logger.Log(undo ? "Uninstalling ..." : "Installing ... ");
using (var inst = new AssemblyInstaller(typeof(Program).Assembly, args))
{
var state = new Hashtable();
inst.UseNewContext = true;
try
{
if (undo)
{
inst.Uninstall(state);
}
else
{
inst.Install(state);
inst.Commit(state);
StartService();
}
}
catch (Exception ex)
{
try
{
Logger.Log(ex);
inst.Rollback(state);
}
catch { }
throw;
}
inst.Dispose();
}
Logger.Log("... finished");
}
catch (Exception ex)
{
Logger.Log(ex);
}
}
示例8: InstallService
/// <summary>
/// 安装windows服务
/// </summary>
/// <param name="serviceName">服务名称</param>
/// <param name="savedState">它用于保存执行提交、回滚或卸载操作所需的信息。</param>
/// <param name="filepath">获取或设置要安装的程序集的路径。</param>
public static void InstallService(String serviceName, IDictionary savedState, string filepath)
{
ServiceController service = new ServiceController(serviceName);
if (!ServiceIsExisted(serviceName))
{
AssemblyInstaller myAssemblyInstaller = new AssemblyInstaller();
myAssemblyInstaller.UseNewContext = true;
myAssemblyInstaller.Path = filepath;
myAssemblyInstaller.Install(savedState);
myAssemblyInstaller.Commit(savedState);
myAssemblyInstaller.Dispose();
service.Start();
}
else
{
if (service.Status != ServiceControllerStatus.Running && service.Status != ServiceControllerStatus.StartPending)
{
service.Start();
}
}
}
示例9: InstallService
/// <summary>
/// 安装服务
/// </summary>
/// <param name="filePath">服务文件路径</param>
/// <param name="serviceName">服务名称</param>
/// <param name="options">选项</param>
public static void InstallService(string filePath, string serviceName, string[] options)
{
try
{
if (!IsServiceExisted(serviceName))
{
IDictionary mySavedState = new Hashtable();
AssemblyInstaller myAssemblyInstaller = new AssemblyInstaller();
myAssemblyInstaller.UseNewContext = true;
myAssemblyInstaller.Path = filePath;
myAssemblyInstaller.CommandLine = options;
myAssemblyInstaller.Install(mySavedState);
myAssemblyInstaller.Commit(mySavedState);
myAssemblyInstaller.Dispose();
}
}
catch (Exception ex)
{
throw new Exception("请以管理员身份启动程序再执行此操作\n" + ex.Message);
}
}
示例10: uninstallmyservice
/// <summary>
/// 卸载服务
/// </summary>
/// <param name="filepath"></param>
public static void uninstallmyservice(string filepath)
{
try
{
AssemblyInstaller assemblyinstaller1 = new AssemblyInstaller();
assemblyinstaller1.UseNewContext = true;
assemblyinstaller1.Path = filepath;
assemblyinstaller1.Uninstall(null);
assemblyinstaller1.Dispose();
}
catch(Exception e)
{
throw new Exception("请以管理员身份启动程序再执行此操作\n" + e.Message);
}
}
示例11: InstallmyService
/// <summary>
/// 安装Windows服务
/// </summary>
/// <param name="stateSaver">集合</param>
/// <param name="filePath">程序文件路径</param>
public static void InstallmyService(IDictionary stateSaver, string filePath)
{
var asmInstaller = new AssemblyInstaller();
asmInstaller.UseNewContext = true;
asmInstaller.Path = filePath;
asmInstaller.Install(stateSaver);
asmInstaller.Commit(stateSaver);
asmInstaller.Dispose();
}
示例12: UnInstallmyService
/// <summary>
/// 卸载Windows服务
/// </summary>
/// <param name="filepath">程序文件路径</param>
public static void UnInstallmyService(string filepath)
{
var asmInstaller = new AssemblyInstaller();
asmInstaller.UseNewContext = true;
asmInstaller.Path = filepath;
asmInstaller.Uninstall(null);
asmInstaller.Dispose();
}
示例13: InstallService
/// <summary>
/// 安装windows服务
/// </summary>
private void InstallService(IDictionary stateSaver, string filepath, string serviceName)
{
try
{
ServiceController service = new ServiceController(serviceName);
if (!ServiceIsExisted(serviceName))
{
AssemblyInstaller myAssemblyInstaller = new AssemblyInstaller();
myAssemblyInstaller.UseNewContext = true;
myAssemblyInstaller.Path = filepath;
myAssemblyInstaller.Install(stateSaver);
myAssemblyInstaller.Commit(stateSaver);
myAssemblyInstaller.Dispose();
service.Start();
}
else
{
if (service.Status != ServiceControllerStatus.Running && service.Status != ServiceControllerStatus.StartPending)
service.Start();
}
}
catch (Exception ex)
{
throw new Exception("InstallServiceError\r\n" + ex.Message);
}
}
示例14: UnInstallService
/// <summary>
/// 卸载Windows服务
/// </summary>
/// <param name="filepath">程序文件路径</param>
public static void UnInstallService(String filepath)
{
AssemblyInstaller AssemblyInstaller1 = new AssemblyInstaller();
AssemblyInstaller1.UseNewContext = true;
AssemblyInstaller1.Path = filepath;
AssemblyInstaller1.Uninstall(null);
AssemblyInstaller1.Dispose();
}
示例15: Main
static void Main(string[] args)
{
var cancelled = false;
var config = args.Where((s) => s.Contains("--config-path=")).SingleOrDefault();
if (!String.IsNullOrEmpty(config))
{
var configFileName = config.Split('=')[1];
if (!String.IsNullOrEmpty(configFileName))
{
_currentConfigPath = Path.Combine(Directory.GetCurrentDirectory(), configFileName);
if (!File.Exists(_currentConfigPath))
throw new FileNotFoundException(String.Format("File {0} is not found in current directory", configFileName));
}
}
ServiceRunner runner = new ServiceRunner(args, LoadTaskHandlerDescriptors());
if (!runner.Options.IsValid)
{
Console.WriteLine(String.Format(runner.GetHelp(), System.IO.Path.GetFileName(Environment.GetCommandLineArgs()[0])));
return;
}
if (runner.Options.RunConsole) // console mode
{
Console.CancelKeyPress += (object sender, ConsoleCancelEventArgs e) => {
e.Cancel = true;
cancelled = true;
Logger.Instance.Info("Exiting...");
runner.Dispose();
return;
};
runner.Start();
WatchServiceAssemblies(Directory.GetCurrentDirectory(), (fname) => {
// Reload the task handlers, not ready yet
if (runner.Options.Mode != MSA.Zmq.JsonRpc.ServiceMode.Router)
{
if (Environment.UserInteractive)
{
PrintMessage("Reloading task handlers...", true);
}
runner.Reload(LoadTaskHandlerDescriptors());
}
});
if (runner.Options.Mode != ServiceMode.None)
while (!cancelled) { }
}
else
{
var serviceAction = runner.Options.ServiceAction;
if (serviceAction == ServiceAction.Install)
{
// install the service with arguments
AssemblyInstaller installer = new AssemblyInstaller(typeof(Program).Assembly, args);
IDictionary state = new Hashtable();
try
{
installer.UseNewContext = true;
if (runner.Options.Mode == ServiceMode.Router || runner.Options.Mode == ServiceMode.MultiWorker ||
runner.Options.Mode == ServiceMode.Worker || runner.Options.Mode == ServiceMode.Publisher)
{
// remove the --install-service arg
var newArgs = args.Where(s => !s.StartsWith("--install-service")).ToArray();
installer.Installers.Add(new ZMQServiceInstaller(runner.Options.ServiceName, newArgs));
}
if (serviceAction == ServiceAction.Install)
{
installer.Install(state);
installer.Commit(state);
}
}
catch (Exception ex)
{
Logger.Instance.Error(ex);
installer.Rollback(state);
throw;
}
finally
{
installer.Dispose();
}
}
else if (serviceAction == ServiceAction.Help)
{
Console.WriteLine(String.Format(runner.GetHelp(), System.IO.Path.GetFileName(Environment.GetCommandLineArgs()[0])));
}
else // run the service
{
ServiceBase.Run(new ZMQService(runner));
}
}
}