-2

I have a problem which I can't solve.

I've made a program which sends a UDP-packet to a certain IP-address.

Here's source code:

byte[] packetData = System.Text.ASCIIEncoding.ASCII.GetBytes("<The Data of Packet>");
string IP = txtIP.ToString();
int Port = Convert.ToInt16(txtPort.Text);
IPEndPoint ep = new IPEndPoint(IPAddress.Parse(IP), Port);
Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,ProtocolType.Udp);
client.SendTo(packetData, ep);

Program asks for IP and port from the user as you can see, but when I try to run this program, I get error message:

'WDoS.Form1' does not contain a definition for 'button1_Click' and no extension method 'button1_Click' accepting a first argument of type 'WDoS.Form1' could be found (are you missing a using directive or an assembly reference?)

I've tried to solve this by myself, but I haven't been able to solve this problem.

4

1 回答 1

3

您可能尝试从表单设计器将事件绑定到 button1。尝试在按钮的属性窗口或自动生成的设计器代码中删除它...

或者这是一个命名/大小写问题。当然它与你的 UDP Socket 无关

于 2013-07-30T13:52:59.967 回答