title: Memory corrupt error
body: <p>I have made one c# application For estate Agent Management. </p>
  
  <p>In that application i have one mdi form which has all the menus in it.</p>
  
  <p>In that menu when i selects agent master , one form comes with Add agent button. </p>
  
  <p>When On Add Agent button is clicked Another Window is opened with agent details to fill.</p>
  
  <p>My problem is>> when i closes this form>></p>
  
  <pre><code>"Attempt to read or write protected memory.This often an indication that other memory is corrupt"
  </code></pre>
  
  <p>Error Comes.
  When i clicks ok on the message box of this application whole application gets closed.</p>
  
  <p>When i normally runs the application through visual studio this error doesnt comes.</p>
  
  <p>But when i runs the exe of the code this error comes.</p>
  
  <p>Is there any solution for this error?</p>
  
  <p>Am i making mistake in releasing or debugging the project?</p>
  
  <p>My stack trace:</p>
  
  <pre><code>See the end of this message for details on invoking 
  just-in-time (JIT) debugging instead of this dialog box.
  
  ************** Exception Text **************
  System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
     at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
     at System.Windows.Forms.NativeWindow.DefWndProc(Message&amp; m)
     at System.Windows.Forms.Control.DefWndProc(Message&amp; m)
     at System.Windows.Forms.Control.WndProc(Message&amp; m)
     at System.Windows.Forms.TextBoxBase.WndProc(Message&amp; m)
     at System.Windows.Forms.TextBox.WndProc(Message&amp; m)
     at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)
     at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m)
     at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  
  
  ************** Loaded Assemblies **************
  mscorlib
      Assembly Version: 2.0.0.0
      Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
      CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
  ----------------------------------------
  Anamol Estate
      Assembly Version: 1.0.0.0
      Win32 Version: 1.0.0.0
      CodeBase: file:///E:/Anamol%20Estate/Anamol%20Estate/Anamol%20Estate/bin/x86/Release/Anamol%20Estate.exe
  ----------------------------------------
  System.Windows.Forms
      Assembly Version: 2.0.0.0
      Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
      CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
  ----------------------------------------
  System
      Assembly Version: 2.0.0.0
      Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
      CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
  ----------------------------------------
  System.Drawing
      Assembly Version: 2.0.0.0
      Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
      CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
  ----------------------------------------
  System.Data
      Assembly Version: 2.0.0.0
      Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
      CodeBase: file:///C:/Windows/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
  ----------------------------------------
  System.Xml
      Assembly Version: 2.0.0.0
      Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
      CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
  ----------------------------------------
  System.Transactions
      Assembly Version: 2.0.0.0
      Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
      CodeBase: file:///C:/Windows/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll
  ----------------------------------------
  System.EnterpriseServices
      Assembly Version: 2.0.0.0
      Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
      CodeBase: file:///C:/Windows/assembly/GAC_32/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
  ----------------------------------------
  System.Configuration
      Assembly Version: 2.0.0.0
      Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
      CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
  ----------------------------------------
  
  ************** JIT Debugging **************
  To enable just-in-time (JIT) debugging, the .config file for this
  application or computer (machine.config) must have the
  jitDebugging value set in the system.windows.forms section.
  The application must also be compiled with debugging
  enabled.
  
  For example:
  
  &lt;configuration&gt;
      &lt;system.windows.forms jitDebugging="true" /&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>When JIT debugging is enabled, any unhandled exception
  will be sent to the JIT debugger registered on the computer
  rather than be handled by this dialog box.</p>