我收到一条错误消息,我不知道如何修复它。这是我的原始代码:
private void SendMessage(Command cmd, EndPoint sendToEP)
{
try
{
//Create the message to send.
Data msgToSend = new Data();
//msgToSend.strName = txtName.Text; //Name of the user.
msgToSend.cmdCommand = cmd; //Message to send.
msgToSend.vocoder = vocoder; //Vocoder to be used.
byte[] message = msgToSend.ToByte();
//Send the message asynchronously.
clientSocket.BeginSendTo(message, 0, message.Length, SocketFlags.None, sendToEP, new AsyncCallback(OnSend), null);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "UniProject-SendMessage ()", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
错误消息是(按钮按下事件)
你调用的对象是空的。
为什么我会收到此错误消息,我该如何解决?