WindowsFirewallHelper icon indicating copy to clipboard operation
WindowsFirewallHelper copied to clipboard

Exception thrown: 'System.NotSupportedException' in WindowsFirewallHelper.dll

Open ctechid opened this issue 2 years ago • 1 comments

I get a warning like this in the immediate window when FirewallManager.Instance.Rules.SingleOrDefault is executed.

I use VS2022 with C# Desktop with Framework 7.0. The program works fine but a warning appears like that. Can it be ignored?

Thanks.

Exception thrown: 'System.Runtime.InteropServices.COMException' in System.Private.CoreLib.dll Exception thrown: 'System.Runtime.InteropServices.COMException' in WindowsFirewallHelper.dll Exception thrown: 'System.NotSupportedException' in WindowsFirewallHelper.dll Exception thrown: 'System.Runtime.InteropServices.COMException' in System.Private.CoreLib.dll Exception thrown: 'System.Runtime.InteropServices.COMException' in WindowsFirewallHelper.dll Exception thrown: 'System.NotSupportedException' in WindowsFirewallHelper.dll

                var wcfHttpRuleInName = String.Format("DiscountCard - WcfHttpRuleIn: Port {0} - Protocol {1}", Settings.Default.ServiceHttpPort, FirewallProtocol.Any);
                var wcfHttpRuleAction = FirewallAction.Allow;
                var wcfHttpRulePort = (ushort)Settings.Default.ServiceHttpPort;
                var wcfHttpRuleProtocol = FirewallProtocol.Any;
                //
                var isWcfHttpRuleInNameFounded = FirewallManager.Instance.Rules.SingleOrDefault(r => r.Name.Equals(wcfHttpRuleInName));
                if (isWcfHttpRuleInNameFounded == null)
                {
                    var ruleIn = FirewallManager.Instance.CreatePortRule(
                        wcfHttpRuleInName,
                        wcfHttpRuleAction,
                        wcfHttpRulePort,
                        wcfHttpRuleProtocol
                    );
                    ruleIn.Direction = FirewallDirection.Inbound;
                    FirewallManager.Instance.Rules.Add(ruleIn);
                }

image

ctechid avatar Apr 08 '23 10:04 ctechid

Do you have break on exception active?

falahati avatar Apr 08 '23 13:04 falahati

answered on #51 and #68

falahati avatar Feb 24 '25 09:02 falahati