How to fix: Not all devices are shown with SharpPcap

Saturday, 21 February 2009 05:32 by Tamir

I already answered this on the CodeProject forums couple of times (1, 2), but I'll repeat it here so it would be easy to find this topic.

This issue is not specific to SharpPcap but rather a Winpcap issue (I beleive it's a Winpcap bug but couldn't find any info about it).

The issue is that if you use winpcap in a multithreaded application, and you try do FindAllDevices() or even PcapOpen() on a dialup device from a new thread, winpcap will fail by specifying that it doesn't find this device.

To workaround the issue you can call GetAllDevices() and PcapOpen() from the main thread and use the new thread to use the already opened device. If you see similar issue even on a single threaded application, adding a [STAThread] attribute on your Main function will probably fix the issue.

Currently rated 3.0 by 46 people

  • Currently 3.043478/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   SharpPcap
Actions:   E-mail | Permalink | Comments (57) | Comment RSSRSS comment feed