PowerPoint Plugin - Error - HRESULT E_FAIL has been returned from a call to a COM component

538 Views Asked by At

I have a problem debugging a project in specific scenario. I'm writing a PowerPoint plugin and when using it with Office 365, it throws following exception

PowerPointApplication_PresentationOpen - Exception: Error HRESULT E_FAIL has been returned from a call to a COM component. Details:
at System.Runtime.InteropServices.ComTypes.IConnectionPoint.Unadvise(Int32 dwCookie) at Microsoft.Office.Interop.PowerPoint.EApplication_EventProvider.remove_AfterNewPresentation(EApplication_AfterNewPresentationEventHandler ) at Microsoft.Office.Interop.PowerPoint.EApplication_Event.remove_AfterNewPresentation(EApplication_AfterNewPresentationEventHandler ) at UI.ThisAddIn.?????????????????????????????????????????(EApplication_Event , EApplication_AfterNewPresentationEventHandler ) at UI.ThisAddIn.set_PowerPointApplication(Application WithEventsValue)
at UI.ThisAddIn.?????????????????????????????????????????(Presentation )

Here's the code where its throwing exception

   Private Sub PowerPointApplication_PresentationOpen(ByVal Pres As PowerPoint.Presentation) Handles PowerPointApplication.PresentationOpen
             PowerPointApplication = Pres.Application
    ...

Here are the pre-requisite to reproduce the issue

  • Office 365
  • Create Presentation and Save It
  • Now, open presentation using PowerPoint open feature and not from recent. and above exception will occur.

I'm using CopyLocal = True. However, when i change Microsoft.Office.Interop.PowerPoint setting to "Embed Interop Type" to True and "CopyLocal" to False then it works fine. Can we fix it by keeping CopyLocal property to True?

1

There are 1 best solutions below

0
Eugene Astafiev On

However, when i change Microsoft.Office.Interop.PowerPoint setting to "Embed Interop Type" to True and "CopyLocal" to False then it works fine. Can we fix it by keeping CopyLocal property to True?

This is a good indicator that something is wrong with your interop assemblies. I'd recommend generating new interop assemblies by removing existing COM references and then re-adding new COM references in Visual Studio. Or just download them from the download center, for example, see Microsoft Office 2010: Primary Interop Assemblies Redistributable. There are no newer versions available, so you can generate them in Visual Studio.