简体   繁体   中英

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

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM