title: Cannot convert from SharpPcap.RawCapture to PacketDotNet.Packet
body: <p>I've been following the guide over at <a href="http://www.codeproject.com/KB/IP/sharppcap.aspx" rel="noreferrer">http://www.codeproject.com/KB/IP/sharppcap.aspx</a> for implementing a simple packet sniffer to automate authentications for me, I've managed to get to the Filtering section, and have had to make some adjustments to the tutorial code so far for it to work, but I am now stumped.</p>
  
  <p>The error I am receiving is;</p>
  
  <blockquote>
    <p>The best overloaded method match for 'PacketDotNet.TcpPacket.GetEncapsulated(PacketDotNet.Packet)' has some invalid arguments</p>
    
    <p>Argument 1: cannot convert from 'SharpPcap.RawCapture' to 'PacketDotNet.Packet'</p>
  </blockquote>
  
  <p>But I've yet to make any references to PacketDotNet my self (everything so far has been SharpPcap).</p>
  
  <p>Entire code I have so far is included, the problem is in the device_OnPacketArrival() function.</p>
  
  <pre><code> using System;
   using System.Collections.Generic;
   using System.Linq;
   using System.Text;
   using PacketDotNet;
   using SharpPcap;
  
   namespace ConsoleApplication1
   {
       class Program
       {
           static void Main(string[] args)
           {
               string ver = SharpPcap.Version.VersionString;
               Console.WriteLine("SharpPcap {0}, Example1.IfList.cs", ver);
  
               // Retrieve the device list
               CaptureDeviceList devices = CaptureDeviceList.Instance;
  
               // If no devices were found print an error
               if (devices.Count &lt; 1)
               {
                   Console.WriteLine("No devices were found on this machine");
                   return;
               }
  
               // Extract a device from the list
               ICaptureDevice device = devices[0];
  
               // Register our handler function to the
               // 'packet arrival' event
               device.OnPacketArrival +=
                   new SharpPcap.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 'Enter' to stop...",
                   device.Description);
  
               // Start capturing packets indefinitely
               device.Capture();
  
               // Close the pcap device
               // (Note: this line will never be called since
               // we're capturing indefinitely
               device.Close();
           }
           private static void device_OnPacketArrival(object sender, CaptureEventArgs e)
           {
               var tcp = TcpPacket.GetEncapsulated(e.Packet);
           }
       }
   }
  </code></pre>