BadImageFormatExeption if targeting NET 4.0, but ok if targeting 4.5

Jan 20, 2014 at 3:54 PM
I've created a project in VS 2013, that uses Pcap.Net, and it's all good.
But the project is by default targeted to NET 4.5, and I would like to use NET 4.0.
If I try to set the project to target NET Framework 4.0, it builds, but at runtime it fails to load the assemblies saying "BadImageFormatExeption".

I use the correct bitness version(x86) and all referenced files (.dll, .xml and *.pdb) are copied at compilation.

Again, if the project targets NET Framework 4.5, it's all good, but not if project targets NET Framework 4.0.

Are the compiled Pcap.Net 0.10.0 (67076) libraries still using NET 4.0 ?
I tried to compile them using VS 2013, but it fails because it calls non-existent tools in my version of SDK.
Jan 24, 2014 at 6:40 AM
Hi expert_vision,

Have you followed the full instructions in Using Pcap.Net in your programs?
Please make sure you followed every step, let me know how it goes.

Jan 28, 2014 at 5:38 PM
Yes, I did follow those instructions. I have installed .NET Framework 4.0 and VC 2010 Redistributable x86 using those links, and the application was built in release mode.
If I set the project in Visual Studio to target NET Framework 4.5, everything works as expected.
If I set it to target NET Framework 4.0, the application starts fine, but as soon as it's trying to use something from "PcapDotNet.Core.dll", I get "BadImageFormatExeption".
I can use PcapNet only with NET Framework 4.5, even though I have installed both 4.0 and 4.5.
Jan 31, 2014 at 6:19 AM
Have you tried switching between the x86 PcapDotNet.Core.dll binary and the x64 one?
Try and change that and consider deleting your bin folder before trying to run it again.