SharpPcap issue
- by Eyla
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()
{
InitializeComponent();
}
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");
return;
}
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;
i++;
}
}
}
}