BadImage Format Exception

Dec 14, 2010 at 9:56 AM
Edited Dec 14, 2010 at 10:21 AM

Hi Boaz, this is shanmuga again.

I have some unhandled exception when running your sample projects.

I give references to dl in Pcap.Net.DevelopersPack.0.7.0.46671.x64 directory

The Exception message is

   BadImage Format Exception was unhandled

   Could not load file or assembly 'PcapDotNet.Core, Version=0.7.0.39675,

   Culture=neutral, PublicKeyToken=4b6f3e583145a652' or one of its dependencies.

   An attempt was made to load a program with an incorrect format.

I am running your samples in VS2010 IDE.

 

This is the code...
simply getting the adapters im my desktop(i have two ethernet cards)...

using System; using System.Collections.Generic; using PcapDotNet.Core; using PcapDotNet.Packets; using PcapDotNet.Packets.Ethernet; using PcapDotNet.Packets.Icmp; using PcapDotNet.Packets.IpV4; namespace SendingASinglePacketWithSendPacket { class Program { static void Main(string[] args) { // Send anonymous statistics about the usage of Pcap.Net PcapDotNet.Analysis.PcapDotNetAnalysis.OptIn = true; // Retrieve the device list from the local machine IList allDevices = LivePacketDevice.AllLocalMachine; if (allDevices.Count == 0) { Console.WriteLine("No interfaces found! Make sure WinPcap is installed."); return; } // Print the list for (int i = 0; i != allDevices.Count; ++i) { LivePacketDevice device = allDevices[i]; Console.Write((i + 1) + ". " + device.Name); if (device.Description != null) Console.WriteLine(" (" + device.Description + ")"); else Console.WriteLine(" (No description available)"); }
        } } }

And i am trying the other dlls in Pcap.Net.DevelopersPack.0.7.0.46671.x86 directory,
this time i am getting another exception .

The Exception message is

   FileNotFoundException was unhandled
  
   Could not load file or assembly 'PcapDotNet.Core.dll' or one of its dependencies.
  
   The specified module could not be found.

I dont know whats happeneing. Is there any supportive dll which i need to include in my project.

If there means tell me

Thanks in advance

g_shanmga
Coordinator
Dec 14, 2010 at 5:19 PM

Hi,

 

Have you followed the "Using Pcap.Net in your programs" section in the User's guide?

You should know if you need 64 bit or 32 bit (according to the OS version). I think you either didn't install the right WinPcap version or the right Microsoft Visual C++ 2010 Redistributable Package.

You can use http://www.dependencywalker.com/ on PcapDotNet.Core.dll to try and see what's missing.

 

Boaz.

Dec 15, 2010 at 4:30 AM

Hi Boaz,

I rectify the problem. I am using 64bit version but my windows is 32 bit.

Thanks .

g_shanmuga

Jan 31, 2012 at 1:17 PM

Hi Everyone,

Today I ran into this problem. I compiled the stuff tagetting platform "AnyCPU". Then I changed to "x86" as I'm testing it in 32bit machine. It started working.

/Srinivas

Coordinator
Jan 31, 2012 at 6:46 PM

Please remember that PcapDotNet.Core has no "Any CPU" configuration, so you must choose whether you want to compile it for 32 bit or 64 bit.

 

I hope this helps,

 

Boaz.

Mar 24, 2013 at 4:19 PM
i also got the g_shanmuga error massage

__Could not load file or assembly 'PcapDotNet.Base, Version=0.10.0.41708, Culture=neutral, PublicKeyToken=d9d89a7aea38cd7c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

i am using 64bit OS and my Winpcap version also 64 bit and i am using Microsoft Visual C++ 2010x64 Redistributable Package 10.0.40219

but the case not solved then i tried the dependencywalker on PcapDotNet.Core.dll it says the following errors

__IESHIMS.DLL-error opening file. the file system cannot find the file specified(2)
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.__
__
can someone help me to fix this issue...
thanx..
Mar 25, 2013 at 4:30 PM
hi.. do we have to use exactly the WinPcap 4.1.2 version ? can we use WinPcap version is 4.1.3 becoz i am using windows 8 64 bit version..
Mar 25, 2013 at 4:30 PM
hi.. do we have to use exactly the WinPcap 4.1.2 version ? can we use WinPcap version is 4.1.3 becoz i am using windows 8 64 bit version..
Mar 25, 2013 at 4:31 PM
hi.. do we have to use exactly the WinPcap 4.1.2 version ? can we use WinPcap version is 4.1.3 becoz i am using windows 8 64 bit version..
Coordinator
Apr 1, 2013 at 9:20 AM
Pcap.Net latest version currently wraps WinPcap 4.1.2.
It makes sense that you'll have problem with WinPcap 4.1.3.