This is a migrated thread and some comments may be shown as answers.

GridViewSynchronizationService Reference Disposed Object...

8 Answers 638 Views
GridView
This is a migrated thread and some comments may be shown as answers.
curtis
Top achievements
Rank 1
curtis asked on 18 Jun 2012, 04:03 AM
Hey Everyone,

I am having an issue regarding the GridViewSynchronizationService trying to reference an object that has been disposed. Here is what I am doing ... I have a form with a grid on it. The user double clicks an entry in the grid, then the id column from the grid is stored into a variable and then passed as a reference to a form that is being opened. As soon as the form opens, the requesting form disposes itself. Upon disposing I receive the following error: Cannot access a disposed object. Object name: 'GridViewSynchronizationService'.

I will attach the code so that you can see what is happening. I have found the only way to avoid this from happening is to add a timer object to the form and have it dispose the form after waiting about 3 seconds, however this simply doesn't feel right.
using System;
using System.Linq;
using System.Windows.Forms;
using PlantManager.Classes;
 
namespace PlantManager.Admin.UserManager
{
    public partial class frmUserManager : Form
    {
        public frmUserManager()
        {
            InitializeComponent();
        }
 
        private void frmUserManager_Load(object sender, EventArgs e)
        {
            LoadData();
        }
 
        private void LoadData()
        {
            QueryAgent qry = new QueryAgent();
            qry.SQLText = "SELECT tbl_Users.UserID,tbl_Users.Username,tbl_Users.FirstName,tbl_Users.LastName,tbl_Users.PhoneExt,tbl_Users.EmailAddress FROM dbo.tbl_Users WHERE tbl_Users.Active = 1";
            qry.exec_SelectQuery();
            dgResults.DataSource = qry.DataSource;
        }
 
        private void mnuEditUser_Click(object sender, EventArgs e)
        {
            EditUser();
        }
 
        private void dgResults_DoubleClick(object sender, EventArgs e)
        {
            EditUser();
        }
 
        private void EditUser()
        {
            string UserID = dgResults.CurrentRow.Cells["UserID"].Value.ToString();
            PubVar.OpenForm("Admin.UserManager.frmEditUser", new string[1] { UserID }, this, true);
            this.Dispose();
        }
    }
}

8 Answers, 1 is accepted

Sort by
0
curtis
Top achievements
Rank 1
answered on 18 Jun 2012, 04:07 AM

Here is the code that is used to open the form ... I added the parameters into the constructor for sending a reference to the requesting form and a parameter for whether or not to close the requesting form thinking that it might have been related to the form not fully opening prior to the requesting form being closed, however I still get the error.

/// <summary>Opens a form with a loading screen.</summary>
 /// <param name="formName">Reference to the form that needs to be opened.</param>
 /// <param name="variables">Reference to variables that need to be passed to opening form.</param>
 /// <param name="RequestingForm"> Form to be closed. Only specify if you want to close the requesting form.</param>
 /// <param name="CloseRequestingForm">Close the requesting form? (true, false)</param>
 public static void OpenForm(string formName, string[] variables, Form RequestingForm, Boolean CloseRequestingForm)
  {
      // Grab the form type.
      Type type = Type.GetType("PlantManager." + formName);
 
      // If form already exists, navigate to it.
      foreach (Form frm in Application.OpenForms)
      {
          if (frm.GetType() == type)
          {
              frm.Dispose();
          }
      }
 
      OpenLoadingScreen();
 
      try
      {
          object[] argVals = new object[] { variables };
 
          // Create a "Type" array of the variable type.
          Type[] types = new Type[1];
          types[0] = typeof(string[]);
 
          // If the form doesn't exists, create it and navigate to it passing in the variables as argVals.
          Form frm2 = type.GetConstructor(types).Invoke(argVals) as Form;
          frm2.MdiParent = Application.OpenForms["frmMainApp"];
          frm2.Show();
          frm2.WindowState = FormWindowState.Maximized;
      }
 
      catch (Exception exception)
      {
          using (Form newForm = new Form())
          {
             ErrHandler.HandleException(exception);
          }
      }
 
      CloseLoadingScreen();
      if (CloseRequestingForm == true)
      {
          RequestingForm.Dispose();
      }
  }

0
Ivan Todorov
Telerik team
answered on 20 Jun 2012, 01:19 PM
Hello Curtis,

Thank you for writing.

This has been logged as issue in our Public Issue Tracking System and can be found on this link. Please check my answer in the support ticket you have opened for additional details.

Kind regards,
Ivan Todorov
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
Anders
Top achievements
Rank 1
answered on 20 Sep 2014, 09:32 PM
Hi, what was the solution to this post? I am getting the same error.

I am setting the value of a filterdescription which haven't been a problem so far. I am using Winforms Q3 2013

Regards
Anders
0
Stefan
Telerik team
answered on 23 Sep 2014, 06:35 AM
Hello Anders,

Here is the link to the same item in our feedback portal: http://feedback.telerik.com/Project/154/Feedback/Details/111465-fix-an-exception-is-thrown-by-radgridview-if-you-dispose-it-on-some-of-its-mouse. The item status is completed and it is scheduled for the upcoming Q3 2014 release, which should be out before the end of October. 

I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

Regards,
Stefan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Robert
Top achievements
Rank 1
answered on 13 Apr 2017, 09:05 AM

Hey,

 

I'm encountering an error very similar to this one.

 

I have a form that contains a radGrid, there is a link from this form to another form.

 

Once an action has been completed on the second form, it feeds information back to the first form which tries to update information on the radGrid.

 

At this point the ragGrid (and entire form for that matter) have become disposed, leading to this error.

 

I'm not sure how to proceed?

 

Thanks,

Robert

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 13 Apr 2017, 10:52 AM
Hello Robert, 

Thank you for writing.  

Following the provided information, I was unable to reproduce the issue you are facing with the latest version. I have attached my sample project. Could you please specify the exact steps how to reproduce the problem? Alternatively, feel free to submit a support ticket and provide a sample project demonstrating the problem. This would be the fastest way to make an adequate analysis of the problem and assist you further. Thank you in advance. 

I am looking forward to your reply.

 Regards,
Dess
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
kwaku
Top achievements
Rank 1
answered on 15 Aug 2017, 10:47 AM
Please I'm having similar issue. I get similar error -"Cannot access disposed object. Object name:GridviewSynchronizationService" when trying to open form in designer view. I don't know where the error is coming from. What should I do?
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 16 Aug 2017, 06:59 AM
Hello , 

Thank you for writing.  

The provided information is not enough for me to replicate the issue locally. If it is a design time problem, I would like to ask you to carefully check the references to all Telerik controls in your project and make sure that they are the same version considering the suffix as well (.20 or .40). Better yet, you can remove all references and add them anew by using the DLLs from your last installation. Delete the license.licx file. After that, you should rebuild your project, close Visual Studio and open it again to make sure that no references are kept in the memory by Visual Studio. 

If you are still experiencing any further difficulties, feel free to submit a support ticket where you can provide additional details and a sample project demonstrating the exact error that you are facing.

I hope this information helps. 

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
curtis
Top achievements
Rank 1
Answers by
curtis
Top achievements
Rank 1
Ivan Todorov
Telerik team
Anders
Top achievements
Rank 1
Stefan
Telerik team
Robert
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
kwaku
Top achievements
Rank 1
Share this question
or