none
Outlook Add-in in C# - Library not registered RRS feed

  • Question

  • Hello,

    I created an outlook add-in that opens a PPTX file, update a few words and save the presentation as a PDF.

    Until 2 days ago, it used to work fine but suddenly, though nothing has changed in my machine, it stopped working.

    It works on my colleagues' machines though ...

    Looking with the debugger, I could see the code causing the issue was as below:

    Application pptApp = new Application();                

    Presentations allpres = pptApp.Presentations;

    The second line returns the error below.

    Unable to cast COM object of type 'Microsoft.Office.Interop.PowerPoint.ApplicationClass' 
    to interface type 'Microsoft.Office.Interop.PowerPoint._Application'. 
    This operation failed because the QueryInterface call on the COM component for the interface with IID '{91493442-5A91-11CF-8700-00AA0060263B}' 
    failed due to the following error: ライブラリは登録されていません。 (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).

    The variable pptApp is not null and looking at the error message, it seems the Presentation interface is not declared.

    I tried to declare the dll referenced in the project for powerpoint, I got an error saying the OCX file does not exists ...

    I tried registering Ole32.dll as suggested on other forums but that did not solved the problem ...

    Would you know what is happening and how I could fix the issue?

    • Moved by CoolDadTx Wednesday, May 21, 2014 1:59 PM Office related
    • Moved by George HuaModerator Friday, May 23, 2014 7:39 AM PowerPoint related
    Wednesday, May 21, 2014 12:12 PM

Answers

All replies

  • Hello,

    Are you able to automate PowerPoint in a standalone .Net based application?

    It looks like the issue is not related to Outlook at all. Am I right?

    Anyway, there is no need to use any OCX or OLE32 files. You just need to add a reference to PowerPoint object library, i.e. interop library. To do this, follow these steps:     

    1. On the Project menu, click Add Reference.
    2. On the COM tab, locate the Microsoft PowerPoint  Object Library and click Select.
    3. Click OK in the Add References dialog box to accept your selections.

    You may find the following articles helpful:

    How to use Automation to create and to show a PowerPoint 2002 presentation by using Visual C# .NET 2002

    How to handle PowerPoint events with Visual C# .NET

    Also I have found a sample project in C# which demonstrates the functionality - C# app automates PowerPoint (CSAutomatePowerPoint) .

    Wednesday, May 21, 2014 2:12 PM
  • If this is an Outlook addin then Application object would apply to an instance of Outlook.Application and not a PPT Application object. That's sort of odd that it worked at all in an Outlook addin.

    Are you starting Outlook or anything else using administrative permissions? That sort of error where things used to work often indicates that user permissions are not consistent in the software you're running.


    Ken Slovak MVP - Outlook

    Wednesday, May 21, 2014 3:19 PM
  • Hi Eugene,

    That's what I'm already doing and it used to work ... 

    I thought too it was not necessary to register anything but looking at the error message, I'm not sure ...

    Thursday, May 22, 2014 5:41 AM
  • \hi Ken, 

    Sorry, I should have specified the Application code stands for Microsoft.Office.Iterop.Powerpoint.Application.

    I don't think anything has changed in rights on my machine.

    The add-in can still create/copy/move/delete files without issue. Only getting the presentations from the PPTX file seems to be a problem ...

    Thursday, May 22, 2014 5:43 AM
  • Do you declare the Application class with the namespace?

    To be sure, I'd recommend declaring the Application class in the code with the namespace or any alias to differentiate Application classes from Outlook and PowerPoint:

    Microsoft.Office.Iterop.Powerpoint.Application

    Thursday, May 22, 2014 6:26 AM
  • It looks like you forgot to answer on my questions:

    Are you able to automate PowerPoint in a standalone .Net based application?

    It looks like the issue is not related to Outlook at all. Am I right?

    Thursday, May 22, 2014 6:26 AM
  • Hi Eugene, 

    Sorry for missing the question.

    I haven't tried a standalone solution. I will try to create one for test purpose.


    Thursday, May 22, 2014 8:20 AM
  • Let me know your results.
    Thursday, May 22, 2014 8:26 AM
  • Hi Eugene,

    I get the same error on the standalone program.

    Except here it happens at this line.

    Microsoft.Office.Interop.PowerPoint.Application pptApp = new Microsoft.Office.Interop.PowerPoint.Application();

    The message is still the same, saying the library is not registered ...

    Thursday, May 22, 2014 9:10 AM
  • Well, it confirms my assumptions that the issue is not related to Outlook. I'd recommend asking such questions in the General Office Development forum instead.

    What error message do you get when trying to instantiate a PowerPoint Application?

    Thursday, May 22, 2014 10:08 AM
  • I don't see how in an Outlook addin an unqualified Application reference can refer to anything  but Outlook.Application. Your code is confusing to me in that respect.

    Ken Slovak MVP - Outlook

    Thursday, May 22, 2014 2:13 PM
  • Hi,

    To use PowerPoint PIA, you need to install Office. For more information, please refer to Office Primary Interop Assemblies.

    >>Unable to cast COM object of type 'Microsoft.Office.Interop.PowerPoint.ApplicationClass' 
    to interface type 'Microsoft.Office.Interop.PowerPoint._Application'. <<

    For this specified issue, the article would help you solve it:

    C#: PPT to PDF-Unable to Cast COM Object of Type 'Microsoft.Office.Interop.PowerPoint. ApplicationClass' to Interface Type 'Microsoft.Office.Interop.PowerPoint. _Application

    Hope this helps.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by kurisutofu Monday, May 26, 2014 2:09 AM
    Friday, May 23, 2014 7:47 AM
    Moderator
  • Hi George,

    Editing the registry as explained in the article you linked did the trick!

    Thank you!

    Monday, May 26, 2014 2:09 AM