I have a function that works fine and when I try to incorporate the code below, it appears that my function is optimized out and just throws an exception:
private bool DumpPcap()
{
string ext = Path.GetExtension(textBox_ServerFilePath.Text);
if (ext.Equals(".pcapng"))
{
// process PCAP file
// Create the offline device
OfflinePacketDevice selectedDevice = new OfflinePacketDevice(textBox_ServerFilePath.Text);
// Open the capture file
using (PacketCommunicator communicator =
selectedDevice.Open(Convert.ToInt32(textBox_ClientPortNumber.Text), // 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
{
// Read and dispatch packets until EOF is reached
communicator.ReceivePackets(0, DispatcherHandler);
}
return true;
}
return false;
}