问题
Executing code that references c:\windows\system32\hnetcfg.dll
to manage the Windows Firewall from this question, causes a BadImageFormatException
as soon as the DLL is loaded.
Opening the 414KB DLL file in NUnit for inspection throws the same exception.
I am running Windows 7. Any solutions?
回答1:
Solved:
...by setting target platform to x86.
回答2:
Is it a 64-bit application trying to reference a 32-bit dll? If so, either get the 64-bit version of the dll or force the application to run in 32-bit using
corflags /32bit+ myApp.exe
Or as you say, just build in 32-bit (x86)
来源:https://stackoverflow.com/questions/4289041/hnetcfg-dll-throws-badimageformatexception