3XLcom
asked on
Referrence error C#
I am getting the following error :
Error 3 The type or namespace name 'CaptureEventArgs' does not exist in the namespace 'SharpPcap' (are you missing an assembly reference?) c:\users\samsung_pc\docume nts\visual studio 2012\Projects\Zynga\Zynga\ Program.cs 70 77 Zynga
how should i resolve the following issue
error.png
Error 3 The type or namespace name 'CaptureEventArgs' does not exist in the namespace 'SharpPcap' (are you missing an assembly reference?) c:\users\samsung_pc\docume
how should i resolve the following issue
error.png
Are you referencing the correct version of that library?
ASKER
yes as you see it is blue
ASKER
should you upload this tested file i tryed tens of time to reinstall references. But not worked for me maybe there is sth. wrong with my comp.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Strange result :
========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
ASKER
when i add all code i get the same result
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _28155859
{
class Program
{
public static void Main(string[] args)
{
// Print SharpPcap version
string ver = SharpPcap.Version.VersionString;
Console.WriteLine("SharpPcap {0}, Example5.PcapFilter.cs\n", ver);
// Retrieve the device list
var devices = CaptureDeviceList.Instance;
// If no devices were found print an error
if (devices.Count < 1)
{
Console.WriteLine("No devices were found on this machine");
return;
}
Console.WriteLine("The following devices are available on this machine:");
Console.WriteLine("----------------------------------------------------");
Console.WriteLine();
int i = 0;
// Scan the list printing every entry
foreach (var dev in devices)
{
Console.WriteLine("{0}) {1}", i, dev.Description);
i++;
}
Console.WriteLine();
Console.Write("-- Please choose a device to capture: ");
i = int.Parse(Console.ReadLine());
var device = devices[i];
//Register our handler function to the 'packet arrival' event
device.OnPacketArrival +=
new PacketArrivalEventHandler(device_OnPacketArrival);
//Open the device for capturing
int readTimeoutMilliseconds = 1000;
device.Open(DeviceMode.Promiscuous, readTimeoutMilliseconds);
// tcpdump filter to capture only TCP/IP packets
string filter = "ip and tcp";
device.Filter = filter;
Console.WriteLine();
Console.WriteLine
("-- The following tcpdump filter will be applied: \"{0}\"",
filter);
Console.WriteLine
("-- Listening on {0}, hit 'Ctrl-C' to exit...",
device.Description);
// Start capture packets
device.Capture();
// Close the pcap device
// (Note: this line will never be called since
// we're capturing infinite number of packets
device.Close();
}
/// <summary>
/// Prints the time and length of each received packet
/// </summary>
private static void device_OnPacketArrival(object sender, CaptureEventArgs e)
{
var time = e.Packet.Timeval.Date;
var len = e.Packet.Data.Length;
Console.WriteLine("{0}:{1}:{2},{3} Len={4}",
time.Hour, time.Minute, time.Second, time.Millisecond, len);
}
}
}
ASKER
Thanks , i realized with this i select wrong framework version