c# - Firewall port is out of range -
code should correct, when run it, says port value out of range (i tried "6" or "1433", need). know wrong?
try { inetfwrule firewallrule = (inetfwrule)activator.createinstance(type.gettypefromprogid("hnetcfg.fwrule")); firewallrule.action = net_fw_action_.net_fw_action_allow; firewallrule.description = rule.text; firewallrule.enabled = true; firewallrule.interfacetypes = "all"; firewallrule.name = rule.text; firewallrule.localports = port.text; firewallrule.protocol = (int)net_fw_ip_protocol_.net_fw_ip_protocol_any; inetfwpolicy2 firewallpolicy = (inetfwpolicy2)activator.createinstance( type.gettypefromprogid("hnetcfg.fwpolicy2")); firewallpolicy.rules.add(firewallrule); } catch (exception ex) { messagebox.show(ex.tostring()); }
Comments
Post a Comment