Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

C# for help........

$
0
0

Forgive my English...

I'm writing a LAN chat.When I run the debug,it can't get the receive content. I make some break point,and I find the it had value yet but lost?And show the message"Object reference not set to an instance of an object".

the code:this is form1

private void DealAcceptedInfo(byte[] recData)
        {.....

case "chat":
                    Form2 content = new Form2(this);
                    content.mess= recvMessage.MsgContent;
                    break;//    I made break point here.And I found content.mess had a value.

.....}

from2:

 public Object messcont = null;
        public Object mess
        {
            get { return messcont; }
            set { messcont = value; }
        }
        private void send()
        {
            if (richTextBox2.Text == "")
                return;
            AddTextBox(string.Format("{0}\t{1}\r\n", label2.Text, DateTime.Now), 1, 1);
            AddTextBox(richTextBox2.Text + "\n", 2, 1);
            Form1 send = new Form1();
            send.listen();
            send.content = richTextBox2.Text;
            sendinfo(send.Sendcontent(label8.Text));
            richTextBox2.Clear();
            this.richTextBox1.ScrollToCaret();
            string messege = Convert.ToString(this.messcont);
            AddTextBox(label2.Text + "    " + DateTime.Now + "\r\n", 1, 2);
            AddTextBox(messege + "\r\n", 2, 2);     //When the code run here,the value lost.
        }

How can I solve it?I am a beginner.


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>