I got the problem. My existing code works only on Windows XP. For Vista or higher it was not working fine. For Vista I need to work with next version of firewall.
Here is the code.
var firewallRule = (INetFwRule2)Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FWRule"));
firewallRule.Name = registerName;
firewallRule.Action = NET_FW_ACTION_.NET_FW_ACTION_ALLOW;
firewallRule.Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_IN;
firewallRule.Enabled = true;
firewallRule.InterfaceTypes = "All";
var rules = VistaFirewallPolicy.Rules;
rules.Add(firewallRule);
This code will add firewall rule to domain, private and public.