I want to manage windows firewall using windows API with .NET C# on dotnet 3.5.
This is what I did.
Type netFwPolicy2Type = Type.GetTypeFromProgID("HNetCfg.FwPolicy2");
var manage = (INetFwPolicy2)Activator.CreateInstance(netFwPolicy2Type);
My application builds successfully in Visual Studio 2017, but when I run it I get the following error:
The program '[3240] firewallmanage.exe' has exited with code -532459699 (0xe0434f4d).
And when I compile in .net 4.5, it works perfectly. Please tell me what went wrong.
I built the program in lower version of .net version and copied the reference DLL(Interop.NetFwTypeLib.dll) from build.This dll was causing the issue because of framework dependency but It started working fine after replacing dll
User contributions licensed under CC BY-SA 3.0