0
\$\begingroup\$

I am trying to make the game add itself into the Firewall rule. I already referenced NetFwTypeLib.dll into the project. It led me to this line of code here:

INetFwPolicy2 fwPolicy2 = Activator.CreateInstance(typeof(INetFwPolicy2)) as INetFwPolicy2;

This gave me an exception of:

MissingMethodException: Default constructor not found for type NetFwTypeLib.INetFwPolicy2

I already tried

Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FwPolicy2"));

which led me to another exception of:

NotImplementedException: Unmanaged activation is not supported

I don't know what to try anymore. Thank you in advance.

\$\endgroup\$
3
  • \$\begingroup\$ Adding a firewall rule requires administrator privs which his not something a game generally needs or should require. See Microsoft Docs. \$\endgroup\$ – Chuck Walbourn Apr 6 '20 at 2:11
  • \$\begingroup\$ @ChuckWalbourn Our game requires a UDP communication with a mobile phone that the firewall automatically blocks. So, that's how it is. \$\endgroup\$ – ruiyl Apr 6 '20 at 6:52
  • \$\begingroup\$ @ChuckWalbourn your tutorial on Direct3D push me through my internship btw. Thank you! \$\endgroup\$ – ruiyl Apr 6 '20 at 6:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.