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\$ Commented Apr 6, 2020 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\$ Commented Apr 6, 2020 at 6:52
  • \$\begingroup\$ @ChuckWalbourn your tutorial on Direct3D push me through my internship btw. Thank you! \$\endgroup\$ Commented Apr 6, 2020 at 6:54

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.