Thread: Error:('WindowsFormsApplication1.Form1.Dispose(boo l)': no suitable method found.....

  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    6

    Error:('WindowsFormsApplication1.Form1.Dispose(boo l)': no suitable method found.....

    Hello every one,
    I am using the Microsoft Visual studio and i have done the first part of C# Server Socket Program,But debugging of Client Socket Program has given this error ('WindowsFormsApplication1.Form1.Dispose(bool)': no suitable method found to override").Kindly help me out.

    The Client socket Program is,

    using System;
    using System.Windows.Forms;
    using System.Net.Sockets;
    using System.Text;

    namespace WindowsApplication1
    {
    public partial class Form1 : Form
    {
    System.Net.Sockets.TcpClient clientSocket = new System.Net.Sockets.TcpClient();

    public Form1()
    {
    InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
    msg("Client Started");
    clientSocket.Connect("127.0.0.1", 8888);
    label1.Text = "Client Socket Program - Server Connected ...";
    }

    private void button1_Click(object sender, EventArgs e)
    {
    NetworkStream serverStream = clientSocket.GetStream();
    byte[] outStream = System.Text.Encoding.ASCII.GetBytes("Message from Client$");
    serverStream.Write(outStream, 0, outStream.Length);
    serverStream.Flush();

    byte[] inStream = new byte[10025];
    serverStream.Read(inStream, 0, (int)clientSocket.ReceiveBufferSize);
    string returndata = System.Text.Encoding.ASCII.GetString(inStream);
    msg("Data from Server : " + returndata);
    }

    public void msg(string mesg)
    {
    textBox1.Text = textBox1.Text + Environment.NewLine + " >> " + mesg;
    }
    }
    }

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Googling the error might help.
    Here is another forum that might help

  3. #3
    Registered User
    Join Date
    Jun 2010
    Posts
    6
    Quote Originally Posted by C_ntua View Post
    Googling the error might help.
    Here is another forum that might help
    i have googled alot but the error is still there... any ways thnx for suggessting another forum.

  4. #4
    Registered User
    Join Date
    Jun 2010
    Posts
    6

    now the Error is different!!

    Now the program is giving the following errors:

    Error 1 The name 'label1' does not exist in the current context

    Error 2 The name 'textBox1' does not exist in the current context



    kindly help me out!!

  5. #5
    Registered User
    Join Date
    Mar 2009
    Location
    england
    Posts
    209
    Sounds like you are attempting to access label1 and textbox1 objects from the outside Form1 class or you are attempting to access objects that do not exist from within Form1 class. Either way it is speculation because you haven't provided code illustrating where the compiler is finding the errors.

    Edit: It's worth really learning the basics of C# before trying to create socket applications and so on. Learn about classes, objects, relationships, inheritance, public and private, static and non static. The errors you have mentioned here are not things that should have you searching the internet for help. There are other problems I can forecast you having in the future, just by the code in your original post, for example you are using "blocking" operations within the GUI thread which is not good practice at all.
    Last edited by theoobe; 06-17-2010 at 01:42 PM.

  6. #6
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Does label1 and textBox1 exist in your Form? You can open the YourForm.Designer.cs file and search for those names.

    If they do, then it is as Theoobe says. Do you maybe have created multiple forms?

  7. #7
    Registered User
    Join Date
    Jun 2010
    Posts
    6
    Quote Originally Posted by theoobe View Post
    Sounds like you are attempting to access label1 and textbox1 objects from the outside Form1 class or you are attempting to access objects that do not exist from within Form1 class. Either way it is speculation because you haven't provided code illustrating where the compiler is finding the errors.

    Edit: It's worth really learning the basics of C# before trying to create socket applications and so on. Learn about classes, objects, relationships, inheritance, public and private, static and non static. The errors you have mentioned here are not things that should have you searching the internet for help. There are other problems I can forecast you having in the future, just by the code in your original post, for example you are using "blocking" operations within the GUI thread which is not good practice at all.
    yeah you are right! but since my "C " is not as good as it should be and also there is a shortage of time for completing my project, so that's why i am taking help from the internet!!!
    wel i wil try my best to learn the things you have mentioned. well, thanks 4 the suggestion!

  8. #8
    Registered User
    Join Date
    Jun 2010
    Posts
    6
    Thanx alot guys. i have solved the problem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Overriding a method in C
    By DavidDobson in forum C Programming
    Replies: 1
    Last Post: 07-05-2008, 07:51 AM
  2. arrays with elements
    By bradleyd in forum C Programming
    Replies: 5
    Last Post: 04-10-2007, 12:00 PM
  3. Logical errors with seach function
    By Taka in forum C Programming
    Replies: 4
    Last Post: 09-18-2006, 05:20 AM
  4. How to pass non-static method to signal() function?
    By registering in forum C++ Programming
    Replies: 3
    Last Post: 11-06-2003, 04:33 PM
  5. Going out of scope
    By nickname_changed in forum C++ Programming
    Replies: 9
    Last Post: 10-12-2003, 06:27 PM