Search code examples
vstooffice-addinsexcel-addinsword-addinspowerpoint-addins

how can I fix this error, The message filter indicated that the application is busy


enter image description here

I keep getting this error in word, excel powerpoint how can i fix it Error=The message filter indicated that the application is busy.
(Execption from HRESULT: 0x8001010A(RPC_E_SERVERCALL_RETRYLATER))

  foreach (Presentation document in Globals.ThisAddIn.Application.Presentations.Cast<Presentation>().ToList())
                    {
                        while (document.ReadOnly!= Microsoft.Office.Core.MsoTriState.msoTrue)
                        {
                            break;
                        }
                 

                        var item = FODocumentRepository.GetByLocalPath(document.FullName);

                        if (item == null)
                        {
                            if (DocHelper.IfFileOrbisDocument(document.FullName))
                            {
                                FODocumentRepository.Add(document.FullName, document.FullName);
                            }
                        }
                    }
  var repositoryList = FODocumentRepository.GetAll().ToList();
  //   var abc = Globals.ThisAddIn.Application.Workbooks.Cast<Workbook>().Select(x => x.FullName).ToList();
  List<FODocument> deleteList = new List<FODocument>();
  foreach (var item in repositoryList)
                    {
                     
                        bool founded = false;
                        foreach (Presentation document in Globals.ThisAddIn.Application.Presentations)
                        {
                            if (item.LocalPath == document.FullName)
                            {
                                founded = true;
                                break;
                            }
                        }
                        if (!founded)
                        {
                            MessageBox.Show("DocumentClosed");
                            FileorbisConflictManager.DocumentClosed(ServiceSettings.GetToken(), DocHelper.GetDocumentKey(item.FOPath),DocumentType.PowerPoint);
                            deleteList.Add(item);
                        }


                    }
  foreach (var item in deleteList)
  {
      FODocumentRepository.Remove(item.LocalPath);
  }


 

Solution

  • These kind of errors occur due to threading contention issues between external multi-threaded applications and Visual Studio. They can be eliminated by implementing IOleMessageFilter error handlers in your Visual Studio automation application. Read more about that in the How to: Fix 'Application is Busy' and 'Call was Rejected By Callee' Errors article.

    Also you can find the same issue described on the Exception thread.