改了半天累了。还是没搞好,发上来大家一起看看吧。。是照着一本书写的
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace SimpleSniff


{

/**//// <summary>
/// Form1 的摘要说明?1br/>
/// </summary>
public class SniffWindow : System.Windows.Forms.Form

{
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.ListBox resultListBox;
private System.Windows.Forms.Button startButton;
private System.Windows.Forms.Button stopButton;
private System.Windows.Forms.Button clearButton;
private System.Windows.Forms.ComboBox addressComboBox;
private System.Windows.Forms.Label label1;
private SniffSocket mySniffSocket;

/**//// <summary>
/// 必需的设计器变量?1br/>
/// </summary>
private System.ComponentModel.Container components = null;
public SniffWindow()

{
//
// Windows 窗体设计器支持所必需?1br/>
//
InitializeComponent();
//
// TODO: ?3#160;InitializeComponent 调用后添加任何构造函数代?1br/>
//
}

/**//// <summary>
/// 清理所有正在使用的资源?1br/>
/// </summary>
protected override void Dispose( bool disposing )

{
if( disposing )

{
if (components != null)

{
components.Dispose();
}
}
base.Dispose( disposing );
}

Windows Form Designer generated code#region Windows Form Designer generated code

/**//// <summary>
/// 设计器支持所需的方?3#160;- 不要使用代码编辑器修?1br/>
/// 此方法的内容?1br/>
/// </summary>
private void InitializeComponent()

{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(SniffWindow));
this.resultListBox = new System.Windows.Forms.ListBox();
this.startButton = new System.Windows.Forms.Button();
this.stopButton = new System.Windows.Forms.Button();
this.clearButton = new System.Windows.Forms.Button();
this.addressComboBox = new System.Windows.Forms.ComboBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// resultListBox
//
this.resultListBox.ItemHeight = 12;
this.resultListBox.Name = "resultListBox";
this.resultListBox.Size = new System.Drawing.Size(288, 208);
this.resultListBox.TabIndex = 0;
this.resultListBox.SelectedIndexChanged += new System.EventHandler(this.resultListBox_SelectedIndexChanged);
//
// startButton
//
this.startButton.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.startButton.Location = new System.Drawing.Point(8, 216);
this.startButton.Name = "startButton";
this.startButton.Size = new System.Drawing.Size(40, 20);
this.startButton.TabIndex = 1;
this.startButton.Text = "开?1/SPAN>";
this.startButton.Click += new System.EventHandler(this.startButton_Click);
//
// stopButton
//
this.stopButton.Location = new System.Drawing.Point(56, 216);
this.stopButton.Name = "stopButton";
this.stopButton.Size = new System.Drawing.Size(40, 20);
this.stopButton.TabIndex = 2;
this.stopButton.Text = "停止";
this.stopButton.Click += new System.EventHandler(this.stopButton_Click);
//
// clearButton
//
this.clearButton.Location = new System.Drawing.Point(104, 216);
this.clearButton.Name = "clearButton";
this.clearButton.Size = new System.Drawing.Size(40, 20);
this.clearButton.TabIndex = 3;
this.clearButton.Text = "清除";
this.clearButton.Click += new System.EventHandler(this.clearButton_Click);
//
// addressComboBox
//
this.addressComboBox.Location = new System.Drawing.Point(200, 216);
this.addressComboBox.Name = "addressComboBox";
this.addressComboBox.Size = new System.Drawing.Size(80, 20);
this.addressComboBox.TabIndex = 4;
this.addressComboBox.Text = "comboBox1";
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Bitmap)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(8, 240);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(144, 32);
this.pictureBox1.TabIndex = 5;
this.pictureBox1.TabStop = false;
//
// label1
//
this.label1.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(224)), ((System.Byte)(224)), ((System.Byte)(224)));
this.label1.Location = new System.Drawing.Point(176, 256);
this.label1.Name = "label1";
this.label1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.label1.Size = new System.Drawing.Size(112, 16);
this.label1.TabIndex = 6;
this.label1.Text = "随想 sjett";
//
// SniffWindow
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 278);

this.Controls.AddRange(new System.Windows.Forms.Control[]
{
this.label1,
this.pictureBox1,
this.addressComboBox,
this.clearButton,
this.stopButton,
this.startButton,
this.resultListBox});
this.Name = "SniffWindow";
this.Text = "SimpleSniff";
this.Load += new System.EventHandler(this.SniffWindow_Load);
this.ResumeLayout(false);
}
#endregion

/**//// <summary>
/// 应用程序的主入口点?1br/>
/// </summary>
[STAThread]
static void Main()

{
Application.Run(new Form1());
}
private void SniffWindow_Load(object sender, System.EventArgs e)

{
ManagementObjectSearcher query1 = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration");
ManagementObjectCollection queryCollection1 = query1.get();
string[] IPString =new string [10];
int x=0;
string[] temp;
foreach (ManagementObject mo in queryCollection1 )

{
temp=mo["IPAddress"] as string[];
if(temp!=null)

{
foreach(string st in temp)

{
IPString[x]=st;
x++;
}
}
}
mySniffSocket=new SniffSocket ();
for(int y=0;y<x;y++)

{
if(IPString[y]!="")
addressComboBox.Items .Add (IPString[y]);
}
addressComboBox.Text =addressComboBox.Items[0] as string;
try

{
mySniffSocket.CreateAndBindSocket (addressComboBox.Text );
}
catch(SniffSocket.SniffSocketException ex)

{
MessageBox.Show (this,ex.Message );
}
mySniffSocket.PacketArrival +=new SniffSocket .PacketArrividEventHandler(DataArrival);
}
private void startButton_Click(object sender, System.EventArgs e)

{
if(mySniffSocket.KeepRunning ==false)

{
mySniffSocket.KeepRunning =true;
try

{
mySniffSocket.Run ();
}
catch(SocketException)

{
mySniffSocket.CreateAndBindSocket (addressComboBox.Text );
mySniffSocket.Run ();
}
startButton.Text ="暂停";
}
else

{
mySniffSocket.KeepRunning =false;
startButton.Text ="Resume";
}
}
private void stopButton_Click(object sender, System.EventArgs e)

{
mySniffSocket.KeepRunning =false;
startButton.Text ="开?1/SPAN>";
Thread.Sleep (10);
mySniffSocket.ShutDown ();
}
private void clearButton_Click(object sender, System.EventArgs e)

{
resultListBox.Items.Clear ();
}
private void resultListBox_DoubleClick(object sender, System.EventArgs e)

{
PacketDisplay dlg=new PacketDisplay (resultListBox.SelectedItem as SniffSocket.PacketArrivedEventArgs);
dlg.show ();
}
private void DataArrival(object sender,SniffSocket.PacketArrivedEventArgs e)

{
resultListBox.Items.Add (e);
}
}
}
这是MainForm.cs
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace SimpleSniff


{

/**//// <summary>
/// PacketDisplay 的摘要说明?1br/>
/// </summary>
public class PacketDisplay : System.Windows.Forms.Form

{
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Label src_addLabel;
private System.Windows.Forms.Label dest_addLabel;
private System.Windows.Forms.Label src_portLabel;
private System.Windows.Forms.Label dest_portLabel;
private System.Windows.Forms.Label protocolLabel;

/**//// <summary>
/// 必需的设计器变量?1br/>
/// </summary>
private System.ComponentModel.Container components = null;
public PacketDisplay(SniffSocket.PacketArrivedEventArgs e)

{
//
// Windows 窗体设计器支持所必需?1br/>
//
InitializeComponent();
src_addLabel.Text =e.OriginationAddress ;
dest_addLabel.Text =e.DestinationAddress ;
src_portLabel.Text =e.OriginationPort ;
dest_portLabel.Text =e.DestinationPort ;
protocolLabel.Text =e.Protocol ;
int x=0;
int y=0;
foreach (byte b in e.MessageBuffer )

{
if(x==0)
listBox1.Items .Add (b.ToString ("x") + "\t");
else
listBox1.Items [y]+=(b.ToString ("x") + "\t");
x++;
if (x>8)

{
x=0;
y++;
}
}
//
// TODO: ?3#160;InitializeComponent 调用后添加任何构造函数代?1br/>
//
}

/**//// <summary>
/// 清理所有正在使用的资源?1br/>
/// </summary>
protected override void Dispose( bool disposing )

{
if( disposing )

{
if(components != null)

{
components.Dispose();
}
}
base.Dispose( disposing );
}

Windows Form Designer generated code#region Windows Form Designer generated code

/**//// <summary>
/// 设计器支持所需的方?3#160;- 不要使用代码编辑器修?1br/>
/// 此方法的内容?1br/>
/// </summary>
private void InitializeComponent()

{
this.src_addLabel = new System.Windows.Forms.Label();
this.dest_addLabel = new System.Windows.Forms.Label();
this.src_portLabel = new System.Windows.Forms.Label();
this.dest_portLabel = new System.Windows.Forms.Label();
this.protocolLabel = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// src_addLabel
//
this.src_addLabel.Location = new System.Drawing.Point(8, 24);
this.src_addLabel.Name = "src_addLabel";
this.src_addLabel.Size = new System.Drawing.Size(72, 16);
this.src_addLabel.TabIndex = 2;
this.src_addLabel.Text = "label1";
//
// dest_addLabel
//
this.dest_addLabel.Location = new System.Drawing.Point(104, 24);
this.dest_addLabel.Name = "dest_addLabel";
this.dest_addLabel.Size = new System.Drawing.Size(80, 16);
this.dest_addLabel.TabIndex = 3;
this.dest_addLabel.Text = "label2";
//
// src_portLabel
//
this.src_portLabel.Location = new System.Drawing.Point(8, 56);
this.src_portLabel.Name = "src_portLabel";
this.src_portLabel.Size = new System.Drawing.Size(72, 16);
this.src_portLabel.TabIndex = 6;
this.src_portLabel.Text = "label3";
//
// dest_portLabel
//
this.dest_portLabel.Location = new System.Drawing.Point(104, 56);
this.dest_portLabel.Name = "dest_portLabel";
this.dest_portLabel.Size = new System.Drawing.Size(80, 16);
this.dest_portLabel.TabIndex = 7;
this.dest_portLabel.Text = "label4";
//
// protocolLabel
//
this.protocolLabel.Location = new System.Drawing.Point(216, 8);
this.protocolLabel.Name = "protocolLabel";
this.protocolLabel.Size = new System.Drawing.Size(72, 16);
this.protocolLabel.TabIndex = 8;
this.protocolLabel.Text = "label5";
//
// label6
//
this.label6.Font = new System.Drawing.Font("宋体", 7.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label6.Location = new System.Drawing.Point(8, 8);
this.label6.Name = "label6";
this.label6.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.label6.Size = new System.Drawing.Size(86, 16);
this.label6.TabIndex = 9;
this.label6.Text = "source address";
//
// label7
//
this.label7.Font = new System.Drawing.Font("宋体", 7.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label7.Location = new System.Drawing.Point(104, 8);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(104, 16);
this.label7.TabIndex = 10;
this.label7.Text = "destination address";
//
// label8
//
this.label8.Font = new System.Drawing.Font("宋体", 7.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label8.Location = new System.Drawing.Point(8, 40);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(72, 16);
this.label8.TabIndex = 11;
this.label8.Text = "source port";
//
// label9
//
this.label9.Font = new System.Drawing.Font("宋体", 7.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label9.Location = new System.Drawing.Point(104, 40);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(88, 16);
this.label9.TabIndex = 12;
this.label9.Text = "destination port";
//
// listBox1
//
this.listBox1.ItemHeight = 12;
this.listBox1.Location = new System.Drawing.Point(0, 80);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(288, 184);
this.listBox1.TabIndex = 13;
//
// PacketDisplay
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 266);

this.Controls.AddRange(new System.Windows.Forms.Control[]
{
this.listBox1,
this.label9,
this.label8,
this.label7,
this.label6,
this.protocolLabel,
this.dest_portLabel,
this.src_portLabel,
this.dest_addLabel,
this.src_addLabel});
this.Name = "PacketDisplay";
this.Text = "PacketDisplay";
this.Load += new System.EventHandler(this.PacketDisplay_Load);
this.ResumeLayout(false);
}
#endregion
}
}
PacketDisplay.cs
using System;
using System.Net;
using System.Net.Sockets;
using System.Runtime.InteropServices;
namespace SimpleSniff


{

/**//// <summary>
/// SniffSocket 的摘要说明?1br/>
/// </summary>
[StructLayout(LayoutKind.Explicit)]
public struct IPHeader

{
[FieldOffset(0)] public byte ip_verlen;
[FieldOffset(1)] public byte ip_tos;
[FieldOffset(2)] public ushort ip_totallength;
[FieldOffset(4)] public ushort ip_id;
[FieldOffset(6)] public ushort ip_offer;
[FieldOffset(8)] public byte ip_ttl;
[FieldOffset(9)] public byte ip_protocol;
[FieldOffset(10)] public ushort ip_checksum;
[FieldOffset(12)] public uint ip_srcaddr;
[FieldOffset(16)] public uint ip_destaddr;
}
public class SniffSocket

{
private bool keepRunning;
private static int rcv_buf_len;
private byte[] rcv_but_bytes;
private Socket socket=null;
private IAsyncResult ar;
public SniffSocket()

{
//
// TODO: 在此处添加构造函数逻辑
//
rcv_buf_len=4096;
rcv_buf_bytes=new byte [rcv_buf_len];
}
public bool KeepRunning

{

get
{return keepRunning;}

set
{keepRunning=value;}
}
public void CreateAndBindSocket(string IP)

{
socket= new Socket (AddressFamily.InterNetwork ,SocketType.Raw ,ProtocolType.IP );
socket.Blocking = false;
socket.Bind (new IPEndPoint (IPAddress.Parse (IP),0));
SetSocketOption();
}
private void SetSocketOption()

{
SniffSocketException ex;
try

{
socket.SetSocketOption (SocketOptionLevel.IP ,SocketOptionName.HeaderIncluded ,1);

byte[] IN=new byte [4]
{1,0,0,0};
byte[] OUT=new byte [4];
int SIO_RCVALL=unchecked ((int)0x98000001);
int ret_code=socket.IOControl (SIO_RCVALL,IN,OUT);
ret_code=OUT[0]+OUT[1]+OUT[2]+OUT[3];
if (ret_code!=0)

{
ex=new SniffSocketException ("command execute error");
throw ex;
}
}
catch (SocketException e)

{
ex=new SniffSocketException ("socket error",e);
throw ex;
}
}
public void ShutDown()

{
if (socket!=null)

{
socket.Shutdown (SocketShutdown.Both );
}
}
public void Run()

{
IAsyncResult ar= socket.BeginReceive (rcv_buf_bytes,0,riv_buf_len,SocketFlags.None ,new AsyncCallback (CallReceive),this);
}
private void CallReceive(IAsyncResult ar)

{
int received_bytes;
received_bytes = socket.EndReceive (ar);
Receive(rcv_but_bytes,received_bytes);
if (keepRunning) Run();
}
unsafe private void Receive(byte [] buf, int len)

{
byte temp_protocol=0;
uint temp_version=0;
uint temp_ip_srcaddr=0;
uint temp_ip_destaddr=0;
short temp_srcport=0;
short temp_detport=0;
IPAddress temp_ip;
PacketArrivedEventArgs e=new PacketArrivedEventArgs ();
fixed (byte *fixed_buf =buf)

{
IPHeader * head = (IPHeader *) fixed_buf;
e.HeaderLength = (uint)(head->ip_verlen & 0x0f) << 2;
temp_protocol =head->ip_protocol ;
switch (temp_protocol)

{
case 1: e.Protocol ="ICMP:"; break;
case 2: e.Protocol ="IGMP:"; break;
case 6: e.Protocol = "TCP:"; break;
case 17: e.Protocol ="UDP:"; break;
default: e.Protocol ="UNKNOWN"; break;
}
temp_version = (uint) (head->ip_verlen & 0xf0) >> 4;
e.IPVersion = temp_version.ToString ();
temp_ip_srcaddr = head->ip_srcaddr ;
temp_ip_destaddr = head->ip_destaddr ;
temp_ip = new IPAddress (temp_ip_srcaddr);
e.OriginationAddress =temp_ip.ToString ();
temp_ip = new IPAddress (temp_ip_destaddr);
e.DestinationAddress = temp_ip.ToString ();
temp_srcport = *(short *) & fixed_buf[e.HeaderLength];
temp_dstport = *(short *) & fixed_buf[e.HeaderLength+2];
e.OriginationPort=IPAddress.NetworkToHostOrder (temp_srcport).Tostring();
e.DestinationPort=IPAddress.NetworkToHostOrder (temp_dstport).Tostring();
e.PacketLength =(uint)len;
e.MessageLength =(uint)len - e.HeaderLength ;
e.ReceiveBuffer =buf;
Array.Copy (buf,0,e.IPHeaderBuffer ,0,(int)e.HeaderLength );
Array.Copy (buf,(int)e.HeaderLength ,e.MessageBuffer ,0,(int)e.MessageLength);
}
OnPacketArrival(e);
}
public class PacketArrivedEventArgs:EventArgs

{
private string protocol;
private string destination_port;
private string origination_port;
private string destination_address;
private string origination_address;
private string ip_version;
private uint total_packet_length;
private uint message_length;
private uint header_lenght;
private byte []receive_buf_bytes = null;
private byte []ip_header_bytes = null;
private byte []message_bytes = null;
public PacketArrivedEventArgs()

{
this.protocol = "";
this.destination_port = "";
this.origination_port = "";
this.destination_address = "";
this.origination_address = "";
this.ip_version = "";
this.total_packet_length = 0;
this.message_length = 0;
this.header_lenght = 0;
this.receive_buf_bytes =new byte[rcv_buf_len];
this.ip_header_bytes =new byte[rcv_buf_len];
this.message_bytes =new byte[riv_buf_len];
}
public string Protocol

{

get
{return protocol;}

set
{protocol=value;}
}
public string DestinationPort

{

get
{return origination_port;}

set
{destination_port=value;}
}
public string OriginationPort

{

get
{return origination_port;}

set
{origination_port=value;}
}
public string DestinationAddress

{

get
{return destination_address;}

set
{destination_address=value;}
}
public string OriginationAddress

{

get
{return origination_address;}

set
{origination_address=value;}
}
public string IPVersion

{

get
{return ip_version;}

set
{ip_version=value;}
}
public uint PacketLength

{

get
{return total_packet_length;}

set
{total_packet_length=value;}
}
public uint MessageLength

{

get
{return message_length;}

set
{message_lenght=value;}
}
public uint HeaderLength

{

get
{return header_length;}

set
{header_length=value;}
}
public byte [] ReceiveBuffer

{

get
{return receive_buf_bytes;}

set
{receive_buf_bytes=value;}
}
public byte [] IPHeaderBuffer

{

get
{return ip_header_buffer;}

set
{ip_header_buffer=value;}
}
public byte [] MessageBuffer

{

get
{return message_bytes;}

set
{message_bytes=value;}
}
public override string ToString()

{
return protocol+origination_address + "\t" + destination_address;
}
}
public delegate void PacketArrivedEventHandler(object sender,PacketArrivedEventArgs args);
public event PacketArrivedEventHandler PacketArrival;
protected virtual void OnPacketArrival(PacketArrivedEventArgs e)

{
if (PacketArrival != null)

{
PacketArrival (this, e);
}
}
public class SniffSocketException:Exception

{
public SniffSocketException():base()

{}
public SniffSocketException(string message):base(message)

{}
public SniffSocketException(string message,Exception innerException):base(message,innerException)

{}
}
}
}
SniffSocket
下面还有一?1br/>
using System;
using System.Windows.Forms;
namespace SimpleSniff


{

/**//// <summary>
/// App 的摘要说明?1br/>
/// </summary>
public class App

{
//
// TODO: 在此处添加构造函数逻辑
//
[STAThread]
public static void Main()

{
try

{
SniffWindow mainWindow= new SniffWindow();
Application.Run (mainWindow);
}
catch(Exception ex)

{
MessageBox.Show (ex.ToString ()+"\n\n"+ex.Message ,"ErrorOccured!");
}
}
}
}
这是App.cs
using System.Reflection;
using System.Runtime.CompilerServices;//注意加了这个引用
..
//
// 有关程序集的常规信息是通过下列
//属性集控制的。更改这些属性值可修改与程序集
//关联的信息?1br/>
//
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//
// 程序集的版本信息包含下列 4 个值:
//
// 主版?1br/>
// 次版?1br/>
// 内部版本?1br/>
// 修订?1br/>
//
// 您可以指定所有值,或使?3#8220;修订?3#8221;?3#8220;内部版本?3#8221;的默认值,方法为按如下方式
// 使用*?1/SPAN>
[assembly: AssemblyVersion("1.0.*")]
//
// 要对程序集进行签名,必须指定要使用的密钥。有关程序集签名的更多信息,请参?3#160;
// Microsoft .NET 框架文档?1br/>
//
// 使用下面的属性控制用于签名的密钥?1br/>
//
// 注意?1br/>
// (*) 如果未指定密钥,则程序集不会被签名?1br/>
// (*) KeyName 是指已经安装在计算机上的
// 加密服务提供程序 (CSP) 中的密钥。KeyFile 是指包含
// 密钥的文件?1br/>
// (*) 如果 KeyFile ?3#160;KeyName 值都已指定,?3#160;
// 发生下列处理?1br/>
// (1) 如果?3#160;CSP 中可以找?3#160;KeyName,则使用该密钥?1br/>
// (2) 如果 KeyName 不存在?3#160;KeyFile 存在,则
// KeyFile 中的密钥安装?3#160;CSP 中并且使用该密钥?1br/>
// (*) 要创?3#160;KeyFile,可以使?3#160;sn.exe(强名称)实用工具?1br/>
// 在指?3#160;KeyFile 时,KeyFile 的位置应该相对于
// 项目输出目录,即
// %Project Directory%\obj\<configuration>。例如,如果 KeyFile 位于
// 该项目目录,应将 AssemblyKeyFile
// 属性指定为 [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
// (*) 延迟签名是一个高级选项 - 有关它的更多信息,请参阅 Microsoft .NET 框架
// 文档?1br/>
//
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]
这是MainForm.csPacketDisplay.csSniffSocket下面还有一?1br/> 这是App.cs