Take the 2-minute tour ×

This is my first time to use SharpPcap library.

I created new project with VC# 2008 and I added SharpPcap as a reference to my project. I post a sample code to get interface of my pc but I'm getting this error:

Error 1 The type or namespace name 'PcapDeviceList' could not be found (are you missing a using directive or an assembly reference?) C:\Users\Ali\Documents\Visual Studio 2008\Projects\Pcap\Pcap\Form1.cs 28 13 Pcap

please advice to solve this problem.

here is my code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SharpPcap;
using SharpPcap.Packets;
using SharpPcap.Protocols;
using SharpPcap.Util;

namespace Pcap
    public partial class Form1 : Form
        public Form1()

        private void button1_Click(object sender, EventArgs e)

            /* Retrieve the device list */
            PcapDeviceList devices = SharpPcap.GetAllDevices();

            /*If no device exists, print error */
            if (devices.Count < 1)
                Console.WriteLine("No device found on this machine");

            int i = 0;

            /* Scan the list printing every entry */
            foreach (PcapDevice dev in devices)
                /* Description */
                label1.Text = "{0}) {1}" + i + dev.PcapDescription +"\n"+

                /* Name */
                "\tName:\t{0}" + dev.PcapName+"\n"+
                /* IP Address */
                "\tIP Address: \t\t{0}"+ dev.PcapIpAddress+"\n"+
                /* Is Loopback */
                "\tLoopback: \t\t{0}"+ dev.PcapLoopback;

share|improve this question
FYI, the examples @ codeproject.com/KB/IP/sharppcap.aspx have been recently been revised to match the current API. –  Evan Plaice Feb 28 '11 at 11:16

3 Answers 3

up vote 5 down vote accepted

What version of SharpPcap are you using?

I'm moving a small in-work project from 2.1.1 to 2.4.1, and parts of the library have changed significantly. I struggled with this myself just a bit ago.

LivePcapDeviceList devices = LivePcapDeviceList.Instance;
    foreach (LivePcapDevice device in devices)
         // Do stuff here...
share|improve this answer

Sorry about the API changes. I'm still trying to get the API named properly. As of v3.0 the API is considerably cleaner and should be a bit more static going forward. If you have any trouble post on the devel list or sf forums and you'll get a quick reply.

Chris SharpPcap maintainer/author http://sharppcap.sf.net

share|improve this answer

Try using Pcap.Net. It's a clear WinPcap wrapper in .NET.

share|improve this answer

Your Answer


