部署NetFwTypeLib来管理Windows防火墙 [英] Deploying NetFwTypeLib to manage the Windows Firewall

查看:2961
本文介绍了部署NetFwTypeLib来管理Windows防火墙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Windows服务,需要创建/从Windows防火墙中删除某些规则。对于 NetFwTypeLib <此I接口;通过COM \system32\hnetcfg.dll ;窗口>。它的伟大工程的我的64位Windows 7机器上的,但在测试其他64位Windows 7的计算机上引发以下错误:

My Windows service needs to create/remove certain rules from the Windows firewall. For this I interface with NetFwTypeLib in <windows>\system32\hnetcfg.dll via COM. It works great on my 64-bit Windows 7 machine, but testing on another 64-bit Windows 7 machine throws the following error:

Service cannot be started. System.IO.FileNotFoundException:
Could not load file or assembly 'Interop.NetFwTypeLib, 
   Version=1.0.0.0, Culture=neutral,
   PublicKeyToken=null' or one of its dependencies.
   The system cannot find the file specified.



我有一种感觉,如果我嵌入并与我的应用程序安装的组件,我早就有问题不同版本的Windows和32位和64位之间。

I have a feeling that if I embed and install the assembly with my application, I would have problems with different versions of Windows and between 32-bit and 64-bit.

我要如何解决这个问题缺少组件部署问题?

How do I solve this missing assembly deployment issue?

编辑:这似乎是一个的除外4.0的目标框架VS2010问题。有没有人有这个修复?

This seems to be a VS2010 issue for any target framework except 4.0. Does anyone have a fix for this?

推荐答案

NetFwTypeLib对象不驻留在hnetcfg.dll库在Windows 7旗舰版。相反,它驻留在FirewallAPI.dll在SYSTEM32%%\FirewallAPI.dll(如c:\windows\system32\FirewallAPI.dll)。

NetFwTypeLib object doesn't reside in hnetcfg.dll library on Windows 7 Ultimate. Rather, it resides in FirewallAPI.dll at %system32%\FirewallAPI.dll (eg c:\windows\system32\FirewallAPI.dll).

使用NetFwTypeLib; //
添加引用
的%SystemRoot%\System32\FirewallAPI.dll

using NetFwTypeLib; // Add reference %SystemRoot%\System32\FirewallAPI.dll

这篇关于部署NetFwTypeLib来管理Windows防火墙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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