Hnetcfg.dll throws BadImageFormatException

Executing code that references c:\windows\system32\hnetcfg.dll to control the Windows firewall from this question raises a BadImageFormatException as soon as the DLL loads.

Opening a 414 KB DLL file in NUnit for verification raises the same exception.

I am running Windows 7. Any solutions?

+1
source share
2 answers

It is decided:

... by installing the target platform on x86.

+4
source

Is this a 64-bit application trying to reference a 32-bit dll? If so, either get the 64-bit version of the dll, or get the application to work in the 32-bit version with

 corflags /32bit+ myApp.exe 

Or, as you say, just create 32-bit (x86)

+4
source

All Articles