rkt_167
Junior Member level 1
- Joined
- Aug 9, 2013
- Messages
- 19
- Helped
- 3
- Reputation
- 6
- Reaction score
- 3
- Trophy points
- 3
- Activity points
- 163
hi all,
I am building a GUI to capture packets received from Ethernet for that I am using Pcap.net libraries in order to open the adapter and capture.
But I am getting this error:
Here is my code:
I am building a GUI to capture packets received from Ethernet for that I am using Pcap.net libraries in order to open the adapter and capture.
But I am getting this error:
Code ActionScript - [expand] 1 A first chance exception of type 'System.Runtime.Serialization.SerializationException' occurred in mscorlib.dll
Here is my code:
Code C# - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 // Take the selected adapter PacketDevice selectedDevice = allDevices[deviceIndex - 1]; // Open the device using (PacketCommunicator communicator = selectedDevice.Open(65536, // portion of the packet to capture // 65536 guarantees that the whole packet will be captured on all the link layers PacketDeviceOpenAttributes.Promiscuous, // promiscuous mode 1000)) // read timeout { Console.WriteLine("Listening on " + selectedDevice.Description + "..."); // Retrieve the packets try { Packet packet; do { p: PacketCommunicatorReceiveResult result = communicator.ReceivePacket(out packet); switch (result) { case PacketCommunicatorReceiveResult.Timeout: // Timeout elapsed continue; case PacketCommunicatorReceiveResult.Ok: Console.WriteLine(packet.Timestamp.ToString("yyyy-MM-dd hh:mm:ss.fff") + " length:" + packet.Length); if (packetdata == null) goto p; else packetdata = ObjectToByteArray(packet.Ethernet); ParseData(packetdata, packetdata.Length); break; default: throw new InvalidOperationException("The result " + result + " shoudl never be reached here"); } } while (true); } catch (Exception ex) { MessageBox.Show(ex.Message, "**ERROR**", MessageBoxButtons.OK, MessageBoxIcon.Error); }