title: Attempted to read or write protected memory. This is often an indication that other memory is corrupt
body: <p>I have written a windows base program which works in a network .</p>
  
  <p>First i had an autocomplete textbox which was reading the names from the databae and shows to the user according to the letter they have entered.</p>
  
  <p>The program was working properly however it sometimes had that error</p>
  
  <p>but</p>
  
  <p>now i have added another autocomplete textbox reading from database, and now the first autocomplete works properly but when i want to fill the second textbox it shows this error and freezes.</p>
  
  <p>The Interesting point is that the program works properly on the server and only shows this error on the client. 
  even it doesnt have any error when i execute it on my laptop or the other laptops i made them a network with my laptop at home, it only has error on the client computer of the office. </p>
  
  <p>please help me with solving this problem.</p>
  
  <p>thank you</p>
  
  <p>the full exception content is :</p>
  
  <pre><code>-----Exception Type Is : UnHandled
  -----Exceptiotn Message is : Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  -----Source that causes this error: System.Windows.Forms
  -----StackTrace is : at System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG&amp; msg)
  at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
  at System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32 reason,ApplicationContext context)
  at System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason,ApplicationContext context)
  at System.Windows.Forms.Application.Run(Form mainForm)
  at Project1.Program.Main() in C:\Users\ZY\Documents\Visual Studio 2008\Projects\Project1\Project1\Program.cs:line 25
  </code></pre>
  
  <p>my autocomplete code is:</p>
  
  <pre><code>private void txtkhrdsharh_TextChanged(object sender, EventArgs e)
     {
  
              AutoCompleteStringCollection namecollection = new     AutoCompleteStringCollection();
              BLL objbll = new BLL();
              SqlDataReader rea = objbll.SelectSharhlistF(txtkhrdsharh.Text);
              if (rea.HasRows == true)
              {
                  while (rea.Read())
                      namecollection.Add(rea["sharh"].ToString());
              }
              rea.Close();
  
              txtkhrdsharh.AutoCompleteMode = AutoCompleteMode.Suggest;
              txtkhrdsharh.AutoCompleteSource = AutoCompleteSource.CustomSource;
              txtkhrdsharh.AutoCompleteCustomSource = namecollection;
      }
  </code></pre>