Help adding pcap.net to my application

Sep 28, 2012 at 7:16 PM

Hi, i need help adding the pcap.net to my application.

Im using this code:

using System;
using System.Collections.Generic;
using PcapDotNet.Core;

namespace ObtainingTheDeviceList
{
    class Program
    {
        static void Main(string[] args)
        {
            // Retrieve the device list from the local machine
            IList<LivePacketDevice> allDevices = LivePacketDevice.AllLocalMachine;

            if (allDevices.Count == 0)
            {
                Console.WriteLine("No interfaces found! Make sure WinPcap is installed.");
                return;
            }

            // Print the list
            for (int i = 0; i != allDevices.Count; ++i)
            {
                LivePacketDevice device = allDevices[i];
                Console.Write((i + 1) + ". " + device.Name);
                if (device.Description != null)
                    Console.WriteLine(" (" + device.Description + ")");
                else
                    Console.WriteLine(" (No description available)");
            }
        }
    }

Thats on the tutorial and im just trying to get it to work with my c# app but its not working.

I even tried adding that code into a c# class but do not know how i can call it into my application. All im trying to do is to display the available devices on a dropdown.

Can anyone please help me?

Thanks.

Coordinator
Oct 5, 2012 at 12:15 PM

Hi mackanga,

 

What do you mean "not working"?

What exactly is wrong (compilation error, linkage error, exception)?

 

Did you follow the "Using Pcap.Net in your programs" section in the User Guide?

 

Boaz.