protected virtual void Dispose(bool disposing) { if (!disposed) { if (disposing) { StopService(); var fw = new FirewallHelper(); var path = Assembly.GetExecutingAssembly().Location; fw.closeFirewall(path,_portNumber); } } //dispose unmanaged resources disposed = true; }
public async Task<bool> RequestFirewallRule() { var fwManager = new FirewallHelper(); string title = ""; Assembly currentAssem = typeof(ServiceRunner).Assembly; object[] attribs = currentAssem.GetCustomAttributes(typeof(AssemblyTitleAttribute), true); if (attribs.Length > 0) { title = ((AssemblyTitleAttribute)attribs[0]).Title; } var path = Assembly.GetExecutingAssembly().Location; return await fwManager.openFirewall(title, path, _portNumber); }