I'm trying to develop a video conferencing app using Visual C#. Here is a chunk of the 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);
}
}
I get a
NullReferenceException at pictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); The method and arguments to the function are all defined. 'ms' has been defined using the 'new' keyword as can be seen.
All the methods have defined references. What am I missing? How should i solve this?