none
Fatal Error after deleting excel file with Post Deployment Action Update RRS feed

  • Question

  • I have an excel customization with a post deployment action following instructions at http://msdn.microsoft.com/en-us/library/dd465291.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1

     I'm trying to copy the excel file with the customisation to the end user's computer. The file is set to check for updates each time it opens. It works fine for install and uninstall. The update code runs OK and replaces the existing file with the updated file but after the code runs I get a fatal com error. I can't figure out how to handle the fatal error so the end user doesn't see it as it happens after the post deployment action.

    Using VS 2010 & Excel 2007.

    Thanks,

    Dylan.

     Select Case args.InstallationStatus

                    Case AddInInstallationStatus.InitialInstall, AddInInstallationStatus.Update

                        Try
                            'check if Excel is open
                            xlApp = Marshal.GetActiveObject("Excel.Application")
                        Catch ex As Exception
                            xlApp = Nothing
                        End Try
                        
                        If Not xlApp Is Nothing Then
                            Try
                                'Excel is open so close file if it is open before trying to delete it
                                xlApp.Workbooks(file).Close(SaveChanges:=False)
                            Catch ex As Exception
                                Exit Try
                            End Try
                        End If


                        If System.IO.Directory.Exists(destPath) Then
                            'If destFile exists delete it before trying to copy in the new file
                            If System.IO.File.Exists(destFile) Then
                                System.IO.File.Delete(destFile)
                            End If
                        Else
                            'Folder doesn't exist yet so create it
                            System.IO.Directory.CreateDirectory(destPath)
                        End If

                        System.IO.File.Copy(sourceFile, destFile)

                        If ServerDocument.IsCustomized(destFile) Then
                            ServerDocument.RemoveCustomization(destFile)
                        End If
                        ServerDocument.AddCustomization(destFile, deploymentManifestUri)

                        Exit Select

                    Case AddInInstallationStatus.Uninstall

                        If System.IO.File.Exists(destFile) Then
                            System.IO.File.Delete(destFile)
                        End If
                        Exit Select

                End Select


    Thursday, April 11, 2013 5:36 AM

All replies

  • what is the COM Error message ? can you provide more error message including error message screenshot and your version of office and OS?  Thanks

    If my post is helpful,please help to vote as helpful, if my post solve your question, please help to make it as answer.

    Thursday, April 11, 2013 1:00 PM
  • Windows 7 enterprise 64, Office 2007. I'm guessing its because I've deleted the file the update code is running on. Error message,

    System.Runtime.InteropServices.COMException (0x8000FFFF): Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
       at Microsoft.VisualStudio.Tools.Applications.Interop.IAppInfo.ReadItem(String elementType, String id)
       at Microsoft.VisualStudio.Tools.Office.Internal.AppInfoContractAdapter.ReadItem(String elementType, String id)
       at Microsoft.VisualStudio.Tools.Office.Internal.IAppInfoProxy.ReadItem(String elementType, String id)
       at Microsoft.VisualStudio.Tools.Applications.AppInfo.ReadCachedDataManifest(IAppInfo appInfo)
       at Microsoft.VisualStudio.Tools.Office.Internal.OfficeAddInAdapterBase.InitializeEntryPointsHelper()

    Thursday, April 11, 2013 11:43 PM
  • In this thread, the initial poster resolved his issue by installing SP. You can also try this.


    with regards, Yuri

    Monday, April 15, 2013 6:50 AM
  • Thanks for the reply Yuri. I have Office SP3 installed and ran updates the other day so I don't think that is the problem.
    Monday, April 15, 2013 7:10 AM
  • I've also tried it with Excel 2010 and VS 2012 and get the same error.
    Wednesday, April 17, 2013 5:37 AM