Windows防火墙允许程序通过Windows Fireall“所有配置文件”进行通信。 [英] Windows Firewall Allow Programs to communicate through Windows Fireall "All Profiles"

查看:86
本文介绍了Windows防火墙允许程序通过Windows Fireall“所有配置文件”进行通信。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我正在使用一个具有公共无效的类GrantAuthorization(字符串applicationFullPath,字符串appName)

I am using a class which has a public void GrantAuthorization(string applicationFullPath, string appName)

我从我的Program.cs调用GrantAuthorization,除了我想允许该程序包含Public,Private和Domain的所有复选框之外,一切正常。

I'm calling the GrantAuthorization from my Program.cs, it all works great except I want to allow the program with all check boxes for Public, Private and Domain.

本课程中有一个部分我尝试这样做,但它永远不会添加其他复选标记,只检查公共。

There is a section in the class where I try to do this but it will never add the other checkmarks, only Public is checked.

               试试
                {

                    fwMgr.LocalPolicy.CurrentProfile.AuthorizedApplications.Add(APPINFO); //这是有用的行

                try
                {
                    fwMgr.LocalPolicy.CurrentProfile.AuthorizedApplications.Add(appInfo); //this is the line that works

//这些添加所有复选标记的尝试都不会做任何事情。

//these attempts to add all checkmarks does nothing.

       ;               fwMgr.LocalPolicy.GetProfileByType(NET_FW_PROFILE_TYPE_.NET_FW_PROFILE_CURRENT).AuthorizedApplications.Add(appInfo);

                     fwMgr.LocalPolicy.GetProfileByType(NET_FW_PROFILE_TYPE_.NET_FW_PROFILE_STANDARD).AuthorizedApplications.Add(appInfo);

                     fwMgr.LocalPolicy.GetProfileByType(NET_FW_PROFILE_TYPE_.NET_FW_PROFILE_TYPE_MAX).AuthorizedApplications.Add(appInfo);

                 }
                catch {}

                    fwMgr.LocalPolicy.GetProfileByType(NET_FW_PROFILE_TYPE_.NET_FW_PROFILE_CURRENT).AuthorizedApplications.Add(appInfo);
                    fwMgr.LocalPolicy.GetProfileByType(NET_FW_PROFILE_TYPE_.NET_FW_PROFILE_STANDARD).AuthorizedApplications.Add(appInfo);
                    fwMgr.LocalPolicy.GetProfileByType(NET_FW_PROFILE_TYPE_.NET_FW_PROFILE_TYPE_MAX).AuthorizedApplications.Add(appInfo);
                }
                catch { }

推荐答案

不要留下"catch"阻止空。而是在那里记录异常。异常消息可能会提供有关指令无效的详细信息。
Don't leave the "catch" block empty. Instead, log the exception there. It's likely that the exception message will provide some detail as to why the instructions are not working.


这篇关于Windows防火墙允许程序通过Windows Fireall“所有配置文件”进行通信。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆