I've run this code:
var device = new OfflinePacketDevice(@"SomeFileWithManyPackets.pcap");
using (var communicator = device.Open())
communicator.SetFilter("ip and udp");
while (packet != null)
And it seems to work.
Maybe some more information would help debugging this:
1. Does the error happens in the first iteration?
2. Can you send me the pcap file you're using?
3. What is the return value from ReceivePacket() when it doesn't throw an exception?
4. Can you write packetFilter() function?
5. Did you make sure you follow all of the instructions in Pcap.Net user guide - Using Pcap.Net in your programs?
6. Does removing the filter prevents this error?
7. Can you minimize the code that reproduces this error?