我正在尝试使用Visual C#开发视频会议应用。这是Start_Sending_Video_Conference的一大块:
private void Start_Sending_Video_Conference(string remote_IP,int port_number)
{
try
{
using ( ms = new MemoryStream())
{
//ms = new MemoryStream();// Store it in Binary Array as Stream
pictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] arrImage = ms.GetBuffer();//returns the array of unsigned bytes
myclient = new TcpClient(remote_IP, port_number);//Connecting with server
myns = myclient.GetStream();//returns the stream
mysw = new BinaryWriter(myns);//encoding
mysw.Write(arrImage);//send the stream to above address
ms.Flush();
mysw.Flush();
myns.Flush();
ms.Close();
mysw.Close();
myns.Close();
myclient.Close();
}
}
catch (Exception ex)
{
Capturing.Enabled = false;
MessageBox.Show(ex.Message,"Video Conference Error Message",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
我得到了
PictureBox1.Image.Save上的NullReferenceException(ms, System.Drawing.Imaging.ImageFormat.Jpeg);方法和参数 功能全部定义。 'ms'已使用'new'定义 可以看到关键字。
所有方法都定义了参考文献。我错过了什么?我该怎么解决这个问题?